hi friends
i need to get the diff between two dates and including the time diff also.
there is a fun datediff from that i got date diff and
how to the time diff?
thanks in advance
with regards
ravi
Printable View
hi friends
i need to get the diff between two dates and including the time diff also.
there is a fun datediff from that i got date diff and
how to the time diff?
thanks in advance
with regards
ravi
Use Timespan, you can ask it to output days, minutes, hours, seconds etc...
Just give it the two dates, then subtract them:
2 Code:
Dim Tspan As TimeSpan Dim date1 As Date = Date.Now Dim date2 As Date = Date.ParseExact("10/06/2007 08:23:14", "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture) Tspan = date1 - date2 MessageBox.Show("Total Hours: " & Tspan.Hours.ToString & " Total Minutes: " & Tspan.Minutes.ToString)
There is also System.DateTime.Subtract
I use this when tracking loading times:
vb.net Code:
Dim start As Date = Now ' Perform function MessageBox.Show(Me, Now.Subtract(start).TotalMilliSeconds)
That will give me the difference in milliseconds.