A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

sum time duration



 
 
Thread Tools Display Modes
  #1  
Old July 7th, 2009, 10:40 PM posted to microsoft.public.access
Frances
external usenet poster
 
Posts: 48
Default sum time duration

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.
  #3  
Old July 7th, 2009, 11:08 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default sum time duration

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]
  #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]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:20 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.