Date/Time

J

Jay

Table has a field named [Time] in second (Number DataType)
I want to format seconds into "HH:mm:ss".

What is wrong with following expression?
[Time]\3600 & ":" & ([Time] Mod 3600)\60 & ":" (([Time] Mod 3600) Mod 60)

Or better yet, best idea, please.
 
J

John Vinson

Table has a field named [Time] in second (Number DataType)
I want to format seconds into "HH:mm:ss".

What is wrong with following expression?
[Time]\3600 & ":" & ([Time] Mod 3600)\60 & ":" (([Time] Mod 3600) Mod 60)

Or better yet, best idea, please.

Well, the Mod 3600 steps aren't necessary; and you will want to use
the Format() function to return two digits for 0 through 9:

Format([Time] \ 3600, "00:") & Format(([Time] \ 60) MOD 60, "00:") &
Format([Time] MOD 60, "00")


John W. Vinson[MVP]
 
D

Douglas J Steele

John Vinson said:
Table has a field named [Time] in second (Number DataType)
I want to format seconds into "HH:mm:ss".

What is wrong with following expression?
[Time]\3600 & ":" & ([Time] Mod 3600)\60 & ":" (([Time] Mod 3600) Mod 60)

Or better yet, best idea, please.

Well, the Mod 3600 steps aren't necessary; and you will want to use
the Format() function to return two digits for 0 through 9:

Format([Time] \ 3600, "00:") & Format(([Time] \ 60) MOD 60, "00:") &
Format([Time] MOD 60, "00")

As well, if you're dealing with less than 24 hours, you can take advantage
of the fact that there are 86,400 seconds in a day, and use

Format([Time]/86400, "h:nn:ss")
 
Top