filtrationproducts
asked on
Format elapsed time format to minutes
I have a column on a table that stores an "elapsed time" in the following format 00:00:00 (HRS:MIN:SEC). I need to divide this time by a quantity.
Is there an easy way to do this, or will I need to break the time down into seconds then do the divide. If so, how do I do this? All these calculations will be done on a report or the query used to pull the data for the report.
Thanks!
Is there an easy way to do this, or will I need to break the time down into seconds then do the divide. If so, how do I do this? All these calculations will be done on a report or the query used to pull the data for the report.
Thanks!
ASKER
That is the most confusing thing I have ever seen.
Can we simplify this?
I need the calculation in VB to change this data "00:06:30" in a text field equaling (6 minutes & 30 seconds) down to only seconds and format it as a simple number (360) so I can use it in a calculation.
Can we simplify this?
I need the calculation in VB to change this data "00:06:30" in a text field equaling (6 minutes & 30 seconds) down to only seconds and format it as a simple number (360) so I can use it in a calculation.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is how simple it is:
?SecondsToText(390)
6 minutes, 30 seconds
?SecondsToText(390)
6 minutes, 30 seconds
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
irudyk,
Does it matter that the "timestudy" field that holds the 00:00:00 time is only a text field?
Does it matter that the "timestudy" field that holds the 00:00:00 time is only a text field?
ASKER
nevermind
No, it doesn't matter. Here is what happens when using the following query formula with a text field of "00:06:30". If used with the 2 functions I provided you get...
SecondsToText((Hour([myTim e])*3600)+ (Minute([m yTime])*60 )+Second([ myTime]))
6 minutes, 30 seconds
SecondsToText((Hour([myTim
6 minutes, 30 seconds
filtrationproducts,
I think we have drifted away from your original question:
"I have a column on a table that stores an "elapsed time" in the following format 00:00:00 (HRS:MIN:SEC). I need to divide this time by a quantity.
Is there an easy way to do this?"
also:
"Does it matter that the "timestudy" field that holds the 00:00:00 time is only a text field?"
I used this, and it worked beautifully,
(Yes, Timestudy is Text in this example)
SELECT tblElapsedTime.TimeStudy, tblElapsedTime.Divisor, Format(CDate([TimeStudy])/ [Divisor], "hh:nn:ss" ) AS Result
FROM tblElapsedTime;
Basically, this converts the Text, (Timestudy), to Date/Time, divides it by the divisor and then formats the result as Date/Time
For example:
1:30:30 divided by 2, results in: 00:45:15
05:22:16 divided by 2, results in: 02:41:08
9:45:09 divided by *3*, results in: 03:15:03
Here is a sample
If this is what you want, great.
If not, then please give an example of your Elapsed Time, a divisor, and the *exact* result you want.
Thanks
JeffCoachman
Access-EEQ23785086-DivideElapsed.mdb
I think we have drifted away from your original question:
"I have a column on a table that stores an "elapsed time" in the following format 00:00:00 (HRS:MIN:SEC). I need to divide this time by a quantity.
Is there an easy way to do this?"
also:
"Does it matter that the "timestudy" field that holds the 00:00:00 time is only a text field?"
I used this, and it worked beautifully,
(Yes, Timestudy is Text in this example)
SELECT tblElapsedTime.TimeStudy, tblElapsedTime.Divisor, Format(CDate([TimeStudy])/
FROM tblElapsedTime;
Basically, this converts the Text, (Timestudy), to Date/Time, divides it by the divisor and then formats the result as Date/Time
For example:
1:30:30 divided by 2, results in: 00:45:15
05:22:16 divided by 2, results in: 02:41:08
9:45:09 divided by *3*, results in: 03:15:03
Here is a sample
If this is what you want, great.
If not, then please give an example of your Elapsed Time, a divisor, and the *exact* result you want.
Thanks
JeffCoachman
Access-EEQ23785086-DivideElapsed.mdb
filtrationproducts
Hmmm, I just re-read your post.
You need minutes only.
Sory about that.
I am sure the other experts here can get you going.
;-)
JeffCoachman
Hmmm, I just re-read your post.
You need minutes only.
Sory about that.
I am sure the other experts here can get you going.
;-)
JeffCoachman
I do not understand why this seems so difficult. I have already provided a function that does what you want.
All you need do is use the code I provided earlier to create two functions. Then in a query use the following substituting "myTime" with the name of the field holding the text data.
SecondsToText((Hour([myTim e])*3600)+ (Minute([m yTime])*60 )+Second([ myTime]))
It couldn't be simpler.
All you need do is use the code I provided earlier to create two functions. Then in a query use the following substituting "myTime" with the name of the field holding the text data.
SecondsToText((Hour([myTim
It couldn't be simpler.
ASKER
sorry for the delay, I dont work on the weekends. But irudyk's code was very simple and did exactally what I wanted.
"In a report set the field's Control Source to:
=(Hour([TimeField])*3600+M inute([Tim eField])*6 0+Second([ TimeField] ))/[Quanti tyField]"
That is the line of code I was looking for. Kudos irudyk.
Also everyone else, thanks for your help!
"In a report set the field's Control Source to:
=(Hour([TimeField])*3600+M
That is the line of code I was looking for. Kudos irudyk.
Also everyone else, thanks for your help!
ASKER
Solution:
=(Hour([TimeField])*3600+M inute(Time Field])*60 +Second(Ti meField])) /[Quantity Field]
=(Hour([TimeField])*3600+M
Open in new window