• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

number conversion problem in Access... need gurus

Mean MrMustard

Diamond Member
(Also posted in Software Forum)

I am building a report in Access. The database records all phone instances i.e. how long a call lasted, how long you were idle, how long a call was on hold, etc... Anyway the database records these numbers in seconds.

For the report I must convert seconds into hours, minutes, and seconds "hh:mm:ss." Can I do this in SQL or do I have to use VBA? I know how to figure it out, that's easy; I just don't know how to code it correctly in VBA. I have a sample of what I'm trying to do.

I guess you could call this pseudocode; its logically correct but not VB code. For instance you had 31081 seconds...

Dim x, y, z, a, b, s, h, m

'gets data from query and finds hours 31081/60 = 518.016/60= 8.63361
x = ([Specialist Master Query].[ACD Time] / 60) / 60

' gets only the whole numbers (roundsdown no matter what) 8
y = rounddown( x )

' 08
h = "0" & y

' (8.63361 - 8) * 60 = 38.016
z = (x - y) * 60

' gets whole number again 38
a = rounddown( z )

' this just makes sure that the minutes will take up 2 digits "00:00:00" 38
If a <= 9 Then
m = "0" & a
Else
m = a
End If

' Int((38.016 - 38) * 60 = 1
b = Int((z - a) * 60)

'same as minutes 01
If b <= 9 Then
s = "0" & b
Else
s = b
End If

'[ACD Time] would be name of the text box that contains the time 08:38:01
[ACD Time] = h & ":" & m & ":" & s

Please post any questions or suggestions. I tried to implement this in a module but to no avail. Oh yeah, this isn't for school as you won't be doing my homework for me. I spent the better part of 5 hours fiddling around with this at work. I don't have internet access at work so I wasn't able to post earlier or google it.
 
Back
Top