Convert seconds to minutes

dc_sc

Registered User.
Local time
Yesterday, 22:21
Joined
May 30, 2003
Messages
24
How do I convert a value like 134 seconds into "2:14". My table has a field of values like this that are numbers and I need a calculation in my query (or report) to change it from seconds to minutes and seconds.
 
Have you tried
DIM NewTime as date, MySecs as long, M as int, S as Int
MySecs = 134
NewTime = DateAdd("s",MySecs,TimeValue("00:00"))
M = Minute(NewTime)
S = Second(NewTime)

Since it is off the top of my head syntax may need adjusting....

Also not sure if DateAdd can take only a time value, you may need to use a whole date and time, but you are ignoring the date as long as it does not cross midnight.
 
Assuming your seconds result is held in a field called SecValue and you want to return a field called MinSec, how about:
MinSec:Int([SecValue]/60)&":"&([Secvalue]-(60*Int([SecValue]/60)))

You can probably tidy that up using the Mod() operator, but I like things that I can understand.

That will return a text value. If you want a field that is formatted as an Access time field, then use
MinSec:[SecValue]/86400
and format the field as nn:ss
 
Last edited:
That last one did the trick. Thanks!
 

Users who are viewing this thread

Back
Top Bottom