Converting Time to Decimal

J

Jase4now

On my form I need to type a length of time in this format 1:30 (1 hour, 30
minutes), but I want it to show and calculate as if I had typed 1.5. I also
would like to not see the "AM" or "PM" if that is possible.


Joel
 
J

Jeff Boyce

What is the data type of the field underlying the control on the form? If
it is a Date/Time data type field, be aware that this is ONLY meant for
'point-in-time' date/time values, not 'duration' (e.g., 1.5 hours).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jase4now

The reports we get show 'Duration' in time format instead of decimal. I need
it to be calculated and converted to decimal. Right now on the table I am
listing these paticular 'text' boxes as 'Date/Time'. Please advise the best
way to accomplish what I need. If that means changing the table, or a
specific code, or both, or something else entirely. I am at the begining
stage of this form, so changes like these won't affect anything yet.

Thanks,
Joel
 
M

Marshall Barton

Jase4now said:
On my form I need to type a length of time in this format 1:30 (1 hour, 30
minutes), but I want it to show and calculate as if I had typed 1.5. I also
would like to not see the "AM" or "PM" if that is possible.


You can enter and display 1:30 as a time value by either
binding the text box to a date/time field in the form's
record source table/query or by setting the text box's
Format property to h:nn

I don't really understand exactly what you want here, but
you can use the value 1.5 in further calculations by using a
simple calulation on the time text box's value. A semi
formal calculation could be:
DateDiff("n", 0, txttime) / 60
or you could use the hack calculation:
txttime * 24

If your further calculations are summing these time
durations, then I strongly suggest that you use the number
of minutes instead of hours.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top