Hello, I have two times that I would like to find the Hours, Minutes, Seconds between. I am using the following code:
VB Code:
Private Function TimeDiff(strTimeIn As String, strTimeOut As String) Dim hour As Long, min As Long, sec As Long sec = DateDiff("s", strTimeIn, strTimeOut) hour = Int(sec / 3600) sec = sec - (hour * 3600) min = Int(sec / 60) sec = sec - (min * 60) TimeDiff = Format(hour, "00") & ":" & Format(min, "00") & ":" & Format(sec, "00") End Function
It works if say I have a TimeIn of 8:00:00AM and a TimeOut of 12:00:00 PM...but if I have a TimeIn of say 01:00:00 PM and a TimeOut of 08:00:00AM (Time diff should be 19 hours)...I get a timediff of -5:00:00. It is going 'back' in time instead of forward. How can I fix this?




Reply With Quote