Number of hours in date range

  • Thread starter Thread starter Totto
  • Start date Start date
T

Totto

Hi,
Is ther a simple way to calculate number of hours in a date range. (dtFrom
as date , dtTo as date)
Had a look at timespan, but can's see that it's possible to add dates.

Tnx
Totto
 
Hi,

Dim ts As New TimeSpan

ts = Now.Subtract(DateTime.Parse("2/2/2004"))

Me.Text = (ts.Days * 24 + ts.Hours).ToString



Ken
 
Hi Totto,

Look at timespan to the methods totalhours, add and subtract. It goes a
little bit on a totally different way than we are used to.

I hope this helps?

Cor
 
* "Totto said:
Is ther a simple way to calculate number of hours in a date range. (dtFrom
as date , dtTo as date)
Had a look at timespan, but can's see that it's possible to add dates.

\\\
Dim ts As TimeSpan = d1.Subtract(d2)
MsgBox(ts.TotalHours.ToString())
///
 
Back
Top