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

  • Thread starter Thread starter Trint Smith
  • Start date Start date
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)
 
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...
 
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
 
* 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)
///
 
Back
Top