Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seconds to Minutes and Hours

Status
Not open for further replies.

yakdogs

Programmer
Aug 13, 2002
40
US
Hello;

I have a field in a report that is coming across as seconds how can I show this as so many hours and then minutes.

I have never done this before.

Can anyone help me?
 
There might be an easier way to do it but this works:

Hours: [seconds]\3600 & ":" & Format(([seconds]-([ seconds]\3600)*3600)\60,"00")

if you want to show the seconds as well then use this:

Hours: [seconds]\3600 & ":" & Format(([seconds]-([ seconds]\3600)*3600)\60,"00") & ":" & [seconds] Mod 60
 
Would this go into the control source of the field?
 
well, you could do it that way in which case the control source would be

=[seconds]\3600 & ":" & Format(([seconds]-([ seconds]\3600)*3600)\60,"00")

but sometime Access will return an error if you try to do that. The other option is to add a field to the query your report is based on and set the control source to that field.
 
MyTim = Format(MySec / 86400., "Short Time")


86400 ~ the number of seconds in a day, so the division converts the seconds to a standard (MS) Date/Time data type. The format simply 'displays' it in the pre-defined format for hours, minutes and seconds. You should be aware that this will truncate any "days", so values of seconds > 86400 will be incorrect.


MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top