468,785 Members | 1,686 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,785 developers. It's quick & easy.

how best to format time duration?

AccessIdiot
493 256MB
This seems like an easy question but I can't for the life of me get it right.

My db users would like to input a time duration, that is the number of hours/min/sec (hh:nn:ss) that a task took. But if I format as time it screws it up. That is, if a task took 24 minutes and 13 seconds and they input 00:24:13 then it goes into the database as 12:24:13 AM.

Is there a way to format number of hours, min, sec without transforming it into a clock time? It would be great if I had a format and an input mask.

Thanks!
Jun 19 '07 #1
3 17503
ADezii
8,800 Expert 8TB
This seems like an easy question but I can't for the life of me get it right.

My db users would like to input a time duration, that is the number of hours/min/sec (hh:nn:ss) that a task took. But if I format as time it screws it up. That is, if a task took 24 minutes and 13 seconds and they input 00:24:13 then it goes into the database as 12:24:13 AM.

Is there a way to format number of hours, min, sec without transforming it into a clock time? It would be great if I had a format and an input mask.

Thanks!
You are trying to assign a duration in hh:mm:ss format to a Date/Time Field. I don't think it will work. Then following should solve your problem:
  1. Create a Field named [Duration] and set its Data Type to Text.
  2. Set the following Input Mask for the Field ==> 00:00:00.
  3. Hours, Minutes, and Seconds can easily be extracted from the [Duration] Field with Calculated Fields as follows:
    Expand|Select|Wrap|Line Numbers
    1. Hours: Mid$([Duration],1,2)
    2. Minutes: Mid$([Duration],3,2)
    3. Seconds: Mid$([Duration],5,2)
  4. Let me know if this is suitable.
Jun 19 '07 #2
AccessIdiot
493 256MB
Ahhh, you nailed it. My mistake was thinking it needed to be a date/time field instead of just a text field. That's all I needed!

Thanks! :-)
Jun 19 '07 #3
NeoPa
32,132 Expert Mod 16PB
For anyone trying to follow, I've just moved a new (hijack) question posted in here across to its own thread as How to Round a Duration.

If you ever notice a thread's been hijacked please take a short minute to click on the Report Abuse button. This link is not simply for personally abusive behaviour but covers anything you feel needs moderator attention (Such as hijacks, spam, etc etc).

Thank you for your co-operation.
Oct 13 '19 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Bart Nessux | last post: by
4 posts views Thread by Gerry Abbott | last post: by
4 posts views Thread by John | last post: by
2 posts views Thread by martin.roclawski | last post: by
3 posts views Thread by Arne Gemsa | last post: by
2 posts views Thread by Praveen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.