Converting decimals to hours and minutes

D

Deenos

I have a number data type field that stores decimals representing time. So
for example the user would type in 1.25 which represents 1 and 1/4 hours. I
need to get Access to sum all the times and then convert it to hours and
mins. and store in a bound field. What is the simplest way to do this?
 
P

pietlinden

I have a number data type field that stores decimals representing time. So
for example the user would type in 1.25 which represents 1 and 1/4 hours.I
need to get Access to sum all the times and then convert it to hours and
mins. and store in a bound field. What is the simplest way to do this?

just do a regular sum. Then
? 630 mod 60
30 <== remainder (minutes)
? 630\60
10 <== hours
 
J

John Spencer

I would store the number or store a string representation.

DateTime fields are points in time - Dec 12, 1944 6:38:01 AM. They do not
store durations 3 hours and 45 minutes very well.

For instance if x is 63.12 then you could use the following expression to
convert that into a string that contains the hours and minutes.

Int(x) & ":" & Format((x - Int(x)) * 60,"00")
63:07

Another option would be to use two number fields. One to store the hours -
Int(x) and one to store the minutes - (x - Int(x)) * 60.


John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
D

Deenos

Thank you John. Where would i put the expression? Using the expression
builder and store the info. in an unbound field or can it be stored in a
bound field. Forgive me I am still a novice at all of this.
 

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