开发者

How to subtract DateTime values and get the Time

What I basically mean and the exact scenario is.

You have 2 TimeEdit controls in an A开发者_JAVA技巧SP.NET page. Those take DateTime values. Now the first represents the time you start working and the second when you finished working. Can take the working hours with an efficient way?

e.g. 10/6/2011 09:00 - 10/6/2011 17:00 --> 08:00 working hours...


Subtracting two DateTimes gives you a TimeSpan object:

TimeSpan span = timeEnd - timeStart;
Console.WriteLine("Total work hours: {0}", span.TotalHours);


Simply subtract them:

var workingTime = dateTimeEnd - dateTimeStart;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜