How to calculate time durations for Star time and End time Difference durations.
for Example Strar Time 10.00AM and End Time 12.00AM.
Thanks&Regs
Manavalan.A
Loading
Virtual. Every session is recorded and published here on CSharp TV.
Answer a question in the forums and earn +2 points for every reply.
Ask a questionKnow the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Feb 29, 2012, 7:37 AM
for C#, Try this.
DateTime time1 = DateTime.ParseExact("23:25:52", "HH:mm:ss", new DateTimeFormatInfo());
DateTime time2 = DateTime.ParseExact("13:15:16", "HH:mm:ss", new DateTimeFormatInfo());
TimeSpan Difftime = time1.Subtract(time2);
for SQL, try..
use DateDiff function but it vary difficult to get in HH:SS format.
SELECT DATEDIFF(hour, '2005-12-31 22:59:59.9999999', '2005-12-31 23:50:00.0000000');
SELECT DATEDIFF(minute, '2005-12-31 22:59:59.9999999', '2005-12-31 23:50:00.0000000');
SELECT DATEDIFF(second, '2005-12-31 22:59:59.9999999', '2005-12-31 23:50:00.0000000');
hope this help