sprucing the time difference

  • Thread starter Thread starter rodchar
  • Start date Start date
R

rodchar

hey all,

datetime startDate
datetime endDate

datetime diff = endDate - startDate

the diff is usually in seconds. is there an easy way to show the seconds as

12 seconds

instead of

7/1/2009 00:00:12:01234

thanks,
rodchar
 
rodchar said:
hey all,

datetime startDate
datetime endDate

datetime diff = endDate - startDate

the diff is usually in seconds. is there an easy way to show the seconds
as

12 seconds

instead of

7/1/2009 00:00:12:01234

thanks,
rodchar

The subtraction operator for DateTimes actually returns a TimeSpan object
(which apparently converts implicitly to a DateTime if your code snippet is
correct). The TimeSpan object has a variety of properties that you can use
to take out the number of seconds, minutes, etc.

Tom Dacon
Dacon Software Consulting
 
Back
Top