I need some 'how to' on time/date strings please...

T

Trint Smith

If I know that I have and ending date and time 2/18/04 and 06:00 am, how
can I take the current time and date 2/17/04 and 07:53 pm and do a
calculation that will show me how many days.hours.seconds are left?
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
C

CJ Taylor

Trint,

The DateTime class has many methods for doing date arithmetic. Have a look
at the msdn collection or your helpful on the DateTime class.

For example, there are several methods for add including
AddDays
Addhours
AddMilliseconds.

etc...
 
B

Brian W

How about the easy way

Dim dt1 As DateTime = DateTime.Parse("2/18/04 06:00 AM")
Dim dt2 As DateTime = DateTime.Parse("2/17/04 07:53 PM")

Dim span As TimeSpan = dt1.Subtract(dt2)

Then take a look at TimeSpan, it will days, hours, minutes, etc.


HTH
Brian W
 
H

Herfried K. Wagner [MVP]

* Trint Smith said:
If I know that I have and ending date and time 2/18/04 and 06:00 am, how
can I take the current time and date 2/17/04 and 07:53 pm and do a
calculation that will show me how many days.hours.seconds are left?

Have a look at 'Microsoft.VisualBasic.DateAndTime.DateDiff' and/or
subtract the dates:

\\\
Dim ts As TimeSpan = d1.Subtract(d2)
///
 
T

Trint Smith

Thanks, I'll try this...and be back!
Trint

.Net programmer
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top