DateDiff

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
I don't think there is one, but, check out TimeSpan, I think that will give
you what you want.


DateTime dt1 = DateTime.Now;
DateTime dt2 = <somoe other date>;

TimeSpan ts = dt1 - dt2;

//Use ts here



HTH
Brian W
 
Jim Heavey said:
What is the C# equivalent of the DateDiff Function in VB?

Not knowing VB, I don't know exactly what DateDiff does. However, if
you have two DateTimes, end and start, you can use:

TimeSpan duration = end-start;
 
DateDiff returns date difference in requested unit (day, minute or stuff
like that).
TimeSpan is good equivalent.
 
Back
Top