Time Conversion

B

Bre-x

If you have work 1 hour 30 Minutes

How do you convert it to 1.50

And viceversa 1.50 to 1h 30m

Thank you all,

Bre-x
 
J

Jeff Boyce

I don't recall a built-in function in Access that does this.

You might be able to find (search on-line) a function that takes a text
string (e.g., "1 hour 30 minutes") and parses it into 1.5 hours. If not,
you'd need to create a procedure to do this ... assuming you start with a
single text string.

If you have two number fields, one for hours, one for minutes, you could use
a query to add two numbers together, one the hours and the other, the
minutes divided by 60 (which gives you fractional hours -- 30/60 = .5).

"How" will depend on "what" -- "what" do you have?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jerry Whittle

Debug.Print CDbl(#01:30#)*24 = 1.5
Debug.Print CDbl([TheTime])*24 = 1.5

The above works if the hours are in a Date/Time field.

Debug.Print CDate(1.5*4.16666666666666E-02) = 1:30:00 AM
 
B

Bre-x

1:30 is store on a date/time field
1.50 is store on a number field (Double)

thank you!!!
 
J

Jeff Boyce

1:30 in a date/time field is a "point-in-time", not a duration.

You can store what looks like a 'duration' in a date/time field, but it
won't behave like one. For example, once you go past 24 hours, you start
over at 00:00 again!

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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

Similar Threads


Top