View Single Post
  #4  
Old July 8th, 2009, 10:00 PM posted to microsoft.public.access
Frances
external usenet poster
 
Posts: 48
Default sum time duration

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" wrote:

On Tue, 7 Jul 2009 14:40:01 -0700, Frances
wrote:

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.
--

John W. Vinson [MVP]