By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,476 Members | 889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,476 IT Pros & Developers. It's quick & easy.

DateTime difference using TimeSpan

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
"=?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

P: n/a
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

P: n/a
"=?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

P: n/a

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

P: n/a
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.