473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 19837
ADezii
8,834 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,556 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

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

Similar topics

8
by: Bart Nessux | last post by:
am I doing this wrong: print (time.time() / 60) / 60 #time.time has been running for many hours if time.time() was (21600/60) then that would equal 360/60 which would be 6, but I'm not getting...
3
by: Steven Scaife | last post by:
I am trying to work out the length of time that a page was opened till it reached another page, I amusing the script below End_Of_Call = formatdatetime(now(), 0) 'work out the duration of the...
4
by: Gerry Abbott | last post by:
Hi All. How can i put a zero decimal for my currency into my format statement, == & ", for " & & " days. Cost " & Format(,"Currency") which is the data source for a textbox on a report
4
by: John | last post by:
Hi I have a start date and a start time field. I also have a timespan value which can be anything from 5 minutes (TimeSpan(0, 5, 0)) to 2 weeks (TimeSpan(14, 0, 0, 0)). How can I get an end date...
2
by: martin.roclawski | last post by:
xsl newbie question: I don't seem to be able to find a simple function to convert a date in DD/MM/YY format to an integer since Epoch. I have the DD/MM/YY value in one mySQL database and trying to...
3
by: Arne Gemsa | last post by:
Hi, I want to get a starttime. To get this I have to subtract the runtime from a unit e.g. 08:40:15 from a date e.g. 2007-03-29 16:48:30. So the starttime is 2007-03-29 08:08:15. Is there any...
2
by: Praveen | last post by:
DateTime.UtcNow is added as root attribute, 'Modified' of an xml whenever xml is changed. Every 5 secs a check is made whether xml is changed or not, by comparing previous 'Modified' and current...
6
by: veer | last post by:
Hi i use Datediff() and it return only hours but i want total time with minutes and seconds at the same time i use following code for all this and it works fine but when the the time came which i...
4
by: ahmurad | last post by:
Dear Brothers, I am struggling the following four Date-Time type values which were inputted into MYSQL database in different tables. As MYSQL Default Time Format: YYYY-MM-DD HH:MM:SS, So I used...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.