length minutes and seconds

B

BBran

How does one get a numeric field representing length of time in seconds, to display as length of time in minutes and seconds? In other words 244 seconds equals 4 minutes and 4 seconds (4:04).
 
D

Douglas J. Steele

So, to give a complete answer, you can write a function like:

Function ConvertToMinutesAndSeconds(TotalSeconds As Long) As String

ConvertToMinutesAndSecond = TotalSeconds \ 60 & _
":" & Format(TotalSeconds Mod 60, "00")

End Function
 
B

BBran

Thank you both very much!

So, to give a complete answer, you can write a function like:

Function ConvertToMinutesAndSeconds(TotalSeconds As Long) As String

ConvertToMinutesAndSecond = TotalSeconds \ 60 & _
":" & Format(TotalSeconds Mod 60, "00")

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top