summing hours and minutes

M

Mike

I have a database storing information about a music
library. One field keeps track of the total playing time
of the CD. Problem - there are 60 minutes in an hour, not
100. Is there some way that I can store the unit's playing
time in hours and minutes and then create reports
accurately summing the field?
(i.e., 0.45 + 0.45 = 1h30m not .9hr)
 
W

Wayne Morgan

It is probably easiest to store that data as the smallest unit available,
minutes or seconds, then format it when you need it.

If in minutes and to display as hours and minutes:

=[TimeField]\60 & "h" & [TimeField] Mod 60 & "m"

The back slash "\" is intentional, it is "integer division".

If you store the data in seconds:

=[TimeField]\3600 & "h" & ([TimeField]\60) Mod 60 & "m" & [TimeField] Mod
3600 Mod 60 & "s"
 
J

John Vinson

I have a database storing information about a music
library. One field keeps track of the total playing time
of the CD. Problem - there are 60 minutes in an hour, not
100. Is there some way that I can store the unit's playing
time in hours and minutes and then create reports
accurately summing the field?
(i.e., 0.45 + 0.45 = 1h30m not .9hr)

I'd suggest instead storing the duration in minutes, rather than
misusing base 10 numbers as if they were Babylonian Base 60. If you
store 90 minutes in a Long Integer field you can use an expression

[PlayingTime] \ 60 & Format([Playing Time] MOD 60, "h00m")

to display it as 1h30m.
 

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