here the issue; when my code runs it does not recognise that 7:00:00 pm is smaller than 24:00. I´m writing in cell D2 =TIME(23,59,59)+TIME(0,0,1)
and the code that is a simple comparison, evaluate true when 7:00:00 > 24:00:00
How can I say with UDF that in cell D2 there is midnight for the proper comparison that I need?
here the code and a screenshot:
Public Function GetTime1(TIn As Date, TOut As Date, TCheckIn As Date, TCheckOut As Date) As Double
Dim Hours As Integer
If Hour(TOut) < Hour(TCheckIn) Then
Hours = DateDiff("h", TCheckIn, TOut)
GetTime1 = TimeSerial(Hours, 0, 0)
ElseIf Hour(TIn) > Hour(TCheckOut) Then
Hours = DateDiff("h", TIn, TCheckOut)
GetTime1 = TimeSerial(Hours, 0, 0)
End If
End Function

Aucun commentaire:
Enregistrer un commentaire