TIME FORMATS

  • Thread starter Thread starter Ian Mills
  • Start date Start date
I

Ian Mills

I am writing a database to record swimming times. Could anyone tell me how
to format the time filed to show

minutes and seconds to 2 decimal places e.g. 1:14.24

Thanks
 
There isn't a way to format seconds with decimal points (and even if you
could, it may not be as accurate as you'd like, given how times are stored).

My suggestion would be to store your times as Long Integers representing
hundreds of seconds. In other words, for 1:14.24, store 7424. Write your own
functions to translated from HundredsOfSeconds to m:ss.dd and from m:ss.dd
to HundredsOfSeconds.

For example, the following untested air-code should convert from
HundredsOfSeconds to m:ss.dd

Function FormatTime(HundredsOfSeconds As Long) As String

Dim lngMinutes As Long
Dim lngSeconds As Long
Dim lngRemainder As Long

lngSeconds = HundredsOfSeconds \ 100
lngRemainder = HundredsOfSeconds - (100 * lngSeconds)
lngMinutes = lngSeconds \ 60
lngSeconds = lngSeconds - (60 * lngMinutes)

FormatTime = Format$(lngMinutes, "0") & ":" & _
Format$(lngSeconds, "00") & "." & _
Format$(lngRemainder, "00")

End Function
 
Back
Top