5 replies
by peyison
The following function should do what you're looking for.
(Paste it into a code module)
------------------------------
Public Function SecondsToStr(ByVal alNumSeconds As Long) As String
Dim lHours As Long
Dim lMinutes As Long
Const SEC_IN_HOUR = 3600
Const SEC_IN_MIN = 60
lHours = alNumSeconds \ SEC_IN_HOUR
alNumSeconds = alNumSeconds - (lHours * SEC_IN_HOUR)
lMinutes = alNumSeconds \ SEC_IN_MIN
alNumSeconds = alNumSeconds - (lMinutes * SEC_IN_MIN)
SecondsToStr= Format$(lHours, "00") & ":" & Format$(lMinutes, "00") & ":" & Format$(alNumSeconds, "00")
End Function
--------------------------------
It can be used in VBA:
Sub TestIt()
MsgBox SecondsToStr(90)
End Sub
Or from a Query:
SELECT SecondsToStr([NumSeconds]) AS SecStr
FROM Table1;
(Where NumSeconds is the name of the field.
Hope this helps.
by hancock
by larry h.
While answer 1 is correct, if you simply need to do this once on your report it might be easier to just create a text box and use the following formula. This assumes that your records have a field called DURATION (in seconds) that you are summing for all records.
=Sum([DURATION])/60/60/24
Then format the text box for time.
by hancock
by hancock
This discussion is closed to new replies.
Trending Software posts
Sort by Trending