Author: RN5A | Posted on: 10/13/2008 12:28:54 AM | Views : 290

This is how I am calculating the time difference:

------------------------
Function TimeDiff(ByVal StartDateTime, ByVal EndDateTime)
    Dim h As Integer
    Dim m As Integer
    Dim t1 As DateTime
    Dim t2 As DateTime
    Dim ts As TimeSpan

    t1 = DateTime.Parse(StartDateTime)
    t2 = DateTime.Parse(EndDateTime)

    ts = t2 - t1
    h = ts.Hours + (ts.Days * 24)
    m = ts.Minutes

    Return System.Math.Abs(h) & ":" & System.Math.Abs(m)
End Function
------------------------

For e.g. if StartDateTime is 05/08/2008 7:00:00 AM & EndDateTime is 05/08/2008 11:30:00 PM, then the above function will return 16:30 i.e. 16 hours & 30 minutes.

The result I am getting from the above function - I am i ...

Go to the complete details ...