469,311 Members | 2,515 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,311 developers. It's quick & easy.

DateTime difference using TimeSpan

I want to use TimeSpan to determine the differences between two date to
include time. My input data is in the following format:

12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM

How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?

I want to have the results expressed in days, hours, minutes and seconds.
Nov 21 '05 #1
5 11296
"=?Utf-8?B?TGFycnkgQmlyZA==?=" <La*******@discussions.microsoft.com> wrote
in news:CE**********************************@microsof t.com:
How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?


You might need to Cdate your string date/times to be accepted as a valid
time format.

You can use DateDiff to get the difference betwen two dates. The results
will be returned as a TimeInterval which has several properties to get the
minutes, hours, days.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2
how can I get the results from "DateDiff" to show all minutes?

Thanks
"Lucas Tam" wrote:
"=?Utf-8?B?TGFycnkgQmlyZA==?=" <La*******@discussions.microsoft.com> wrote
in news:CE**********************************@microsof t.com:
How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?


You might need to Cdate your string date/times to be accepted as a valid
time format.

You can use DateDiff to get the difference betwen two dates. The results
will be returned as a TimeInterval which has several properties to get the
minutes, hours, days.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 21 '05 #3
"=?Utf-8?B?TGFycnkgQmlyZA==?=" <La*******@discussions.microsoft.com>
wrote in news:C4**********************************@microsof t.com:
how can I get the results from "DateDiff" to show all minutes?

http://msdn.microsoft.com/library/de...l=/library/en-
us/cpref/html/frlrfSystemTimeSpanClassTopic.asp
You would use the TotalMinutes property.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #4

Try it this way:
' Create two valid dates
Dim dLast As Date = CDate([strDate])
Dim dNow As Date = Now

Dim iTime As TimeSpan = dNow.Subtract(dLast)

iTime.Minutes returns the minutes of the TimeSpan object.

Hope this helps,
Dennis
"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
I want to use TimeSpan to determine the differences between two date to
include time. My input data is in the following format:

12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM

How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?

I want to have the results expressed in days, hours, minutes and seconds.

Nov 21 '05 #5
This what I've been looking for and trying to do.

Thanks

"Dennis Powell" wrote:

Try it this way:
' Create two valid dates
Dim dLast As Date = CDate([strDate])
Dim dNow As Date = Now

Dim iTime As TimeSpan = dNow.Subtract(dLast)

iTime.Minutes returns the minutes of the TimeSpan object.

Hope this helps,
Dennis
"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
I want to use TimeSpan to determine the differences between two date to
include time. My input data is in the following format:

12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM

How do I get TimeSpan to accept my input?

How do I get the difference between two dates using TimeSpan?

I want to have the results expressed in days, hours, minutes and seconds.


Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jeff Shantz | last post: by
15 posts views Thread by Fritz Switzer | last post: by
1 post views Thread by JIM.H. | last post: by
2 posts views Thread by Mike | last post: by
8 posts views Thread by ajs | last post: by
1 post views Thread by =?Utf-8?B?RGFwcGVyRGFuSEBub3NwYW0ubm9zcGFt?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.