Hi Pablo,
I'm not sure of you are trying to do exactly, but the following
function might give you an idea:
================================================
Function TimeDiff(varFrom As Variant, varTo As Variant) As Variant
Dim lngHours As Long
Dim lngMinutes As Long
Dim lngSeconds As Long
Dim ReturnValue As String
If (IsNull(varFrom) Or IsNull(varTo)) Then
Exit Function
End If
If Not (IsDate(varFrom) Or IsDate(varTo)) Then
Exit Function
End If
lngSeconds = DateDiff("s", varTo, varFrom)
lngHours = lngSeconds \ 3600
lngSeconds = lngSeconds - (lngHours * 3600)
lngMinutes = lngSeconds \ 60
lngSeconds = lngSeconds - (lngMinutes * 60)
ReturnValue = _
IIf(lngHours = 1, lngHours & "hr ", IIf(lngHours > 1, lngHours
& "hrs ", ""))
ReturnValue = ReturnValue & _
IIf(lngMinutes = 1, lngMinutes & "min ", IIf(lngMinutes > 1,
lngMinutes & "mins ", ""))
ReturnValue = ReturnValue & _
IIf(lngSeconds = 1, lngSeconds & "sec ", IIf(lngSeconds > 1,
lngSeconds & "secs ", ""))
TimeDiff = ReturnValue
End Function
================================================
This is a simplified version of a function I currently use. It has not
been fully tested!
Hope it helps,
Mario R. Osorio
"Begin with the end in mind"