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

seconds to hours:mins

Status
Not open for further replies.

TheEnigma

Technical User
May 26, 2002
69
US
Hi there,
Can anyone help me please? I want to turn a field in my query from seconds into hours:minutes.

So another words 8019 would now be 2:13
 
this code will give you a string representation of hours and minutes.

Dim vSeconds as long
Dim vElapsedTime as string
vSeconds = 8019
vElapsedTime = CLng((vSeconds / 3600) - 0.5) & ":" & CInt(((vSeconds - (CLng((vSeconds / 3600) - 0.5) * 3600)) / 60) - 0.5)

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Great. I know this is VBA code but I figured you could figure to use it in your query okay.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Yeah all I had to do was enter this in (I replaced vSeconds with the field name of TotalCallTime):

TotalCallTime: CLng(([TotalTime]/3600)-0.5) & ":" & CInt((([TotalTime]-(CLng(([TotalTime]/3600)-0.5)*3600))/60)-0.5)

And it works like a charm! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top