the problem as follows:
TOut = 11:00:00 PM
TCheckIn = 10:00:00 PM
in my code, select case, stop at the first condition and the result is -1:00:00 (I figured out with ABS function).
here the code:
Public Function TIMECOMPARE(TIn As Date, TOut As Date, TCheckIn As Date, TCheckOut As Date) As Double
Dim Hours As Integer
Select Case TIMECOMPARE
Case Hour(TOut) < Hour(TCheckIn)
Hours = Hour(TCheckIn) - Hour(TOut)
TIMECOMPARE = TimeSerial(Hours, 0, 0)
Case Hour(TIn) > Hour(TCheckOut)
Hours = Hour(TIn) - Hour(TCheckOut)
TIMECOMPARE = TimeSerial(Hours, 0, 0)
Case Hour(TIn) < Hour(TCheckIn) And Hour(TOut) < Hour(TCheckOut)
Hours = Hour(TOut) - Hour(TCheckIn)
TIMECOMPARE = TimeSerial(Hours, 0, 0)
End Select
End Function
Someone can help me to understand what I am not understanding? the case where should stop is the third....