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

Converting Seconds to hh:nn:ss 2

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I have a report that shows the total time someone is logged into their phone. The data is in seconds, so I take the sum of the seconds/86400 and format the text box as hh:nn:ss and i get the desired result if I am only looking at one days worth of data. If it spans multiple days the data it shown incorrectly.

If this was excel i would change the format from hh:mm:ss to [h]:mm:ss and it would rectify it. Is there something similar in access?

Thanks for any suggestions!

Paul
 


hi,

Convert Seconds DURATION to DAYS and use the Format() function to return the text structure desired.

If you have multiple days worth, you must convert the seconds to days for each value and then subtract the Date/Time values to get DURATION (END - START)

BTW, if you had SECONDS in Excel, you would STILL need to convert Seconds to Days, in order to format as you suggested.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I would create a small user-defined function that concatenates the number of hours and the formatted minutes and seconds:
Code:
Public Function HoursTime(datTime As Date) As String
    Dim intHrs As Integer
    intHrs = Int(datTime * 24)
    HoursTime = intHrs & ":" & Format(datTime, "nn:ss")
End Function
You will need to divide the seconds by 86400 to send to the function.

Duane
Hook'D on Access
MS Access MVP
 
Dhookom, that worked perfectly, thank you so much!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top