Hi All,
Always i feel Time calculation bit hectic than anything..
Please consider the following Rules for Time Calculation:
1.
Working hours is only considered 11.30 hours (One full day is 11.30 not 24 hours)...
if date A = 24/05/2011 05:08:56
if date B = 26/05/2011 07:08:58
2.
only fully day is 11.30( 10.30 - 22.00) ...So for first and last day we have to subract and add the time (we can not take it as 11.30 hours).
Output
I want to subract Two dates and Produce Output as Hours:Minutes:Seconds
Advanced Thanks
Loading

Jiteendra SampathiraoRank #585 · 4.1K reputationPosted May 30, 2011, 3:04 AM EDT
Try this:
DateTime strdt= Convert.ToDateTime("04/14/2011");
DateTime enddt= Convert.ToDateTime("04/07/2010");
TimeSpan ts = strdt.Subtract(enddt);
int day = ts.Days;
VulpesRank #55 · 29.2K reputationPosted May 30, 2011, 3:40 AM EDT
This should give an answer of 23:00:00 because there's a full day on 24 May (from 10.30 to 22.00), a full day on 25 May but no hours are worked on 26 May because the finishing time is before 10.30.
Sam HobbsRank #108 · 20.5K reputationPosted May 30, 2011, 11:58 AM EDT