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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Seconds To HH:MM:SS 1

Status
Not open for further replies.

quinbe

Programmer
Dec 30, 2004
62
0
0
US
Hi all,
I have a table with ActionID, Date, StartTime and EndTime.
The start time I have is in time format. The end time which is the duration of action is in seconds. The question how to convert it to HH:MM:SS format
Thanks for any help
 
If your EndTime field is just a number, here's one way to mask it like a time - note that it's still just a number but it gives the right format if you want to use it in queries, reports, code, etc.
Code:
EndTime\3600 & ":" & Format((EndTime\60) Mod 60,"00") & ":" & Format(EndTime Mod 60,"00")
{/code]
If you try to convert the field straight to a time format using the Format() function, Access thinks your number of seconds is a number of days, and so gives the wrong result.

Hope this helps.

[pc2] [URL unfurl="true"]http://www22.brinkster.com/accessory/[/URL]
 
I'm not really familiar with coding in Access. I don't know where the code suppose to be. Could you please tell a bit more how it's gonna work. And what is the field is double, is it should work with the same coding.
Thanks
 
Why not simply this ?
Format(EndTime/86400, "hh:nn:ss")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for your response, PHV
I coppied "EndTime/86400, "hh:nn:ss" to Format. I tried to type 200.36 (in second). When I review it, this line "(EndTime/86400 hh:nn:ss)" appears, and when I click on the field, I can see the number that I typed. When I click on different fields then the line "(EndTime/86400 hh:nn:ss)" appears again. How do I fix this?
 
A starting point:
Create a textbox named, say, txtformattedEndTime and with the following ControlSource property:
=Format([EndTime]/86400, "hh:nn:ss")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
It works very nice.
I greatly thank for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top