sum time duration

F

Frances

I am making a database of musical compositions each with several tracks
lasting just a few minutes and seconds . I want to be able to sum the
duration of the tracks for each compositon.
Please can you tell me how to do this? I have tried formatting the field
'Duration' as 'Date/Time' but how can I designate it as minutes:seconds and
not the hours:minutes of Short time? Then how would I sum the times?
I tried choosing short time and put an input mask of __:__but when I summed
the field I got a decimal number.
Thank you for any help you can give.
 
J

John W. Vinson

I am making a database of musical compositions each with several tracks
lasting just a few minutes and seconds . I want to be able to sum the
duration of the tracks for each compositon.
Please can you tell me how to do this? I have tried formatting the field
'Duration' as 'Date/Time' but how can I designate it as minutes:seconds and
not the hours:minutes of Short time? Then how would I sum the times?
I tried choosing short time and put an input mask of __:__but when I summed
the field I got a decimal number.
Thank you for any help you can give.

I would suggest storing the duration in a Long Integer field holding seconds
(e.g. a track that runs 4 minutes 15 seconds would contain 255). Date/Time
fields are designed to store a specific point in time, not a duration, and
don't add/subtract well. (The decimal you're getting is fractions of a day,
the unit used for date/time).

You can display a duration in minutes:seconds with an expression

=Duration\60 & ":" & Format([Duration] MOD 60, "00")

In addition you can have minutes and seconds textboxes on a form, and move
data to and from these with some simple code.
 
F

Frances

Hi John, Thank you very much for the suggestion. The result I obtained when
i put the expression in a query gave Duration\60 as a decimal, the seconds
were ok.

My son found out that the following modifications work which are just
slightly different.

Displays mm:ss
TotDur: [Duration]\60 & Format([Duration] Mod 60,"\:00")

Displays hh:mm:ss
TotDur2: [Duration]\3600 & Format(([Duration]\60) Mod 60,"\:00") &
Format([Duration] Mod 60,"\:00")


John W. Vinson said:
I am making a database of musical compositions each with several tracks
lasting just a few minutes and seconds . I want to be able to sum the
duration of the tracks for each compositon.
Please can you tell me how to do this? I have tried formatting the field
'Duration' as 'Date/Time' but how can I designate it as minutes:seconds and
not the hours:minutes of Short time? Then how would I sum the times?
I tried choosing short time and put an input mask of __:__but when I summed
the field I got a decimal number.
Thank you for any help you can give.

I would suggest storing the duration in a Long Integer field holding seconds
(e.g. a track that runs 4 minutes 15 seconds would contain 255). Date/Time
fields are designed to store a specific point in time, not a duration, and
don't add/subtract well. (The decimal you're getting is fractions of a day,
the unit used for date/time).

You can display a duration in minutes:seconds with an expression

=Duration\60 & ":" & Format([Duration] MOD 60, "00")

In addition you can have minutes and seconds textboxes on a form, and move
data to and from these with some simple code.
 

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