Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 date difference issue

Author  Topic 

olay80
Yak Posting Veteran

62 Posts

Posted - 2005-04-08 : 03:53:04
hey guys,

in VB we use DateDiff(s, D1, D2) to calculate difference between two dates in seconds, is there a similar function in C#?

thanx,
Oliver

rfrancisco
Yak Posting Veteran

95 Posts

Posted - 2005-04-08 : 10:20:10
Try this:

D1.Subtract(D2).Seconds
Go to Top of Page

olay80
Yak Posting Veteran

62 Posts

Posted - 2005-04-11 : 09:54:39
thanx,
this is for the rest to know:

System.DateTime tt = System.DateTime.Parse(sStartDate);
System.DateTime tt1 = System.DateTime.Parse(sEndDate);
System.TimeSpan span = tt1.Subtract(tt);
double numberHours = span.TotalHours;

//where the sStartDate and sEndDate are string values.

Oliver
Go to Top of Page
   

- Advertisement -