PC Review


Reply
Thread Tools Rate Thread

DateTime difference using TimeSpan

 
 
=?Utf-8?B?TGFycnkgQmlyZA==?=
Guest
Posts: n/a
 
      17th Aug 2004
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.
 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      17th Aug 2004
"=?Utf-8?B?TGFycnkgQmlyZA==?=" <(E-Mail Removed)> wrote
in news:CE6405DE-CB3B-486B-AF31-(E-Mail Removed):

> 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 ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
=?Utf-8?B?TGFycnkgQmlyZA==?=
Guest
Posts: n/a
 
      17th Aug 2004
how can I get the results from "DateDiff" to show all minutes?

Thanks


"Lucas Tam" wrote:

> "=?Utf-8?B?TGFycnkgQmlyZA==?=" <(E-Mail Removed)> wrote
> in news:CE6405DE-CB3B-486B-AF31-(E-Mail Removed):
>
> > 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 ((E-Mail Removed))
> Please delete "REMOVE" from the e-mail address when replying.
> http://members.ebay.com/aboutme/coolspot18/
>

 
Reply With Quote
 
Lucas Tam
Guest
Posts: n/a
 
      17th Aug 2004
"=?Utf-8?B?TGFycnkgQmlyZA==?=" <(E-Mail Removed)>
wrote in news:C42A80DC-5B96-4585-8F56-(E-Mail Removed):

> 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 ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
Dennis Powell
Guest
Posts: n/a
 
      18th Aug 2004

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" <(E-Mail Removed)> wrote in message
news:CE6405DE-CB3B-486B-AF31-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
=?Utf-8?B?TGFycnkgQmlyZA==?=
Guest
Posts: n/a
 
      18th Aug 2004
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" <(E-Mail Removed)> wrote in message
> news:CE6405DE-CB3B-486B-AF31-(E-Mail Removed)...
> > 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.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
TimeSpan.TotalDays versus DateTime.ToOADate difference =?Utf-8?B?RGFwcGVyRGFuSEBub3NwYW0ubm9zcGFt?= Microsoft C# .NET 1 19th Nov 2007 02:12 AM
add timespan to datetime Lars Schouw Microsoft C# .NET 3 22nd May 2007 11:17 AM
How do I convert a DateTime table column to a TimeSpan or DayOfWeek ? Harry Haller Microsoft ASP .NET 0 21st Jul 2005 12:35 PM
convert timespan to time/datetime...? =?Utf-8?B?VmluYXk=?= Microsoft Dot NET Compact Framework 3 4th May 2005 09:32 AM
DateTime / TimeSpan Greater Than 23:59:59 =?Utf-8?B?SmVmZiBTaGFudHo=?= Microsoft C# .NET 2 2nd Jul 2004 05:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:56 AM.