DATEDIFF得到其间2日的日期,并将其绑定到GridView [英] Datediff getting the date inbetween 2 dates and bind it to a gridview
问题描述
我有'dateborrowed'和'datereturned列的表。我想要做的就是我想在'之间datereturned'和'dateborrowed并将其绑定到另一个表的另一列中的值。还可以如何使用DATEDIFF函数它怎么办?我还在学习它在其间。任何帮助将大大AP preciated。
I have a table with 'dateborrowed' and 'datereturned' column. What I want to do is I want to get the value in between 'datereturned' and 'dateborrowed' and bind it to another column in another table. Also how can I do it using datediff function? I'm still learning it in the meantime. Any help would be greatly appreciated.
在此先感谢!
推荐答案
使用C#.NET可以减去一个的DateTime
从另一个,造成了时间跨度
。例如:
With C#.NET you can subtract one DateTime
from another, resulting in a TimeSpan
. For example:
TimeSpan timespan = (DateTime.Now - new DateTime(2011, 1, 1));
如果你想在两个日期之间的日期,可以再加入一半的时间跨度到日期之一:
If you want a date in between two dates, you can then add half of this timespan to one of the dates:
TimeSpan timespan = (DateTime.Now - new DateTime(2011, 1, 1));
DateTime inBetween = DateTime.Now.AddDays(timespan.TotalDays / 2);
这篇关于DATEDIFF得到其间2日的日期,并将其绑定到GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!