Click to See Complete Forum and Search --> : Time Diff


October 28th, 1999, 02:19 AM
Dear all,

I have two times captured in a table using the 'time' command. I know how to work out the time in minutes, seconds, and hours....but i wanted to say return me the time difference in hours, minutes and seconds....without ending up with 1856 seconds difference.....i wanted say 2 mins 30 seconds....can anyone pls help.

Lothar Haensler
October 28th, 1999, 03:14 AM
Here is some VB 6 sample code to calculate the datetime difference between 2 dates.

private Sub Command1_Click()
Dim d1 as date
Dim d2 as date
d1 = #10/26/1999 12:00:00 PM#
d2 = #11/15/1999 2:15:00 PM#
Dim diff as date
diff = d2 - d1
MsgBox Day(diff) & " days " & Hour(diff) & " hours " & Minute(diff) & " minutes"
End Sub