![]() |
|
|
|||||||
![]() |
ASP Net - Difference in seconds from two datetime objects |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
How can I find the difference in seconds of two DateTime objects. I have
looked at the Subtract method but this gives me back another DateTime object. Thanks, Ron Ron |
|
|
|
|
#2 |
|
Posts: n/a
|
Ron wrote:
> How can I find the difference in seconds of two DateTime objects. I have > looked at the Subtract method but this gives me back another DateTime > object. Actually, DateTime.Subtract( TimeSpan) returns a DateTime object, but DateTime.Subtract( DateTime) gives you a TimeSpan object. The TotalSeconds property of this will give you what you want: (datetime2.Subtract( datetime1)).TotalSeconds or (datetime2 - datetime1).TotalSeconds Be careful not to mistakenly use the "Seconds" property of the TimeSpan object, as this only gives you the seconds *component* of the TimeSpan, which will always be in the range 0-59. -- mikeb mikeb |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Difference between H.264 and xVID | ivan | DVD Video | 4 | 10-20-2009 03:25 AM |
| is VooDoo 2+Riva TNT 2,16MB AGP, combo make any difference in 3D-render performance ? | niljaviya | Hardware | 0 | 11-03-2006 04:35 AM |
| DVI to HDMI converters and Vis versa any difference ? | Helllo | DVD Video | 0 | 02-02-2005 01:31 AM |
| the leopard DVD: Criterion vs Bfi - is there likely to be a big difference? | Jim | DVD Video | 14 | 09-09-2004 08:14 AM |
| PAL vs NTSC - difference in pitch??? Help! | Sam | DVD Video | 14 | 07-27-2003 09:48 AM |