|
|
Кол-во часов (дробное)по значениям полей начала и окончания (работы)
Public Function TotalTimeInHours(vStartHH As Variant, vStartNN As Variant, vEndHH As Variant, vEndNN As Variant) As Currency
'es 06.03.2019
Dim dStart As Date, dEnd As Date
Dim dRes As Date
On Error GoTo TotalTimeInHours_Err
dStart = TimeSerial(Nz(vStartHH), Nz(vStartNN), 0)
dEnd = TimeSerial(Nz(vEndHH), Nz(vEndNN), 0)
If dEnd = dStart Then GoTo TotalTimeInHours_End
If dEnd < dStart Then GoTo TotalTimeInHours_Err
dRes = dEnd - dStart
TotalTimeInHours = CCur(Format(dRes, "hh"))
TotalTimeInHours = TotalTimeInHours + CCur(Format(dRes, "nn") / 60)
TotalTimeInHours_End:
On Error Resume Next
Err.Clear
Exit Function
TotalTimeInHours_Err:
Err.Clear
TotalTimeInHours = -1
Resume TotalTimeInHours_End
End Function
MSA-2007 ( 49 kB) Пример
|
|