Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Difference in seconds from two datetime objects

 
Thread Tools Search this Thread
Old 03-04-2004, 11:30 PM   #1
Default Difference in seconds from two datetime objects


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
  Reply With Quote
Old 03-05-2004, 12:41 AM   #2
mikeb
 
Posts: n/a
Default Re: Difference in seconds from two datetime objects
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46