mrkehd
asked on
Converting seconds to minute:second
I'm wondering if anyone has any suggestions for truncating the decimals in a calculated field in a query. The field seems to ignore the property setting for zero decimal places. As indicated by my subject I have a field ([avg speed ans]) that displays data in a total number of seconds in which the calculated field ([asa_mins]) converts to minutes (e.g. 120 seconds is calculated to 2 minutes), yet if the number of seconds doesn't come out to a nice, even number of minutes:seconds it displays several decimal places (e.g. 122 seconds gets converted to 3:20.754379272). How could I truncate this? Is it some form of usage of MID$ or something similar? Below is the calculated field. Thanks in advance for any suggestions!
ASA_Mins: Int([AvG Speed Ans]/60) & ":" & ([AvG Speed Ans]-(60*Int([AvG Speed Ans]/60)))
ASA_Mins: Int([AvG Speed Ans]/60) & ":" & ([AvG Speed Ans]-(60*Int([AvG Speed Ans]/60)))
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Use the ROUND function, but you are right, it looks like it should do the right thing - especially if int([avg speed ans]/60) does return a 2... maybe best to use dattime functions e.g. using an arbitrary date...
format((dateadd("s",122,#0 1/01/2008 00:00:00#) - #01/01/2008 00:00:00# ),"hh:mm:ss")
should give you 00:02:02
format((dateadd("s",122,#0
should give you 00:02:02
Thanks, glad to help. You realize my solution is limited to any 59 minutes 59 seconds. If you have any number larger than that, then make the format string "hh:nn:ss". this will give you leading zeroes for anything under one hour.
If still not working for you, you can try wrapping with Round(value, 0) to round to zero decimal places.