La siguiente función obtiene la diferencia entre dos horas pasadas. Para que la función funcione correctamente la hora inicial (dtStartTime) debe ser inferior a la final (dtStopTime), y la hora debe estar en formato 24H. La función devuelve el intervalo (strInterval) en horas (h), minutos (n) o segundos s).

Public Function TimeDiff(strInterval As String, dtStartTime As Date, dtStopTime As Date) As Long
TimeDiff = DateDiff(strInterval, #12:00:00 AM#, Format(TimeValue(dtStartTime) – 1 – TimeValue(dtStopTime), “hh:nn:ss”))
End Function

Fuente: UtterAccess

Leave a Reply