# Thread: Convert Decimal hours

1. ## Convert Decimal hours (on computer)

K, I can do it on paper but how do I get a peice of software like excel
to convert 1.3 hours to 1hr 18min or 01:18?

Any help?

2. Hi:

Given input hours=h,

h hrs = floor(h) hrs, 60*(h-floor(h)) min.

Ex.: input: h=1.3
flr(h)=flr(1.3)=1
60*(h-floor(h)) = 60*(1.3 - 1) = 60*0.3 = 18.

Output: 1.3 hrs = 1hr, 18 min.

Notes: (h-floor(h)) is just the "fractional" component, 0.3 in the given example. Substitutions are, therefore, frac(h) and (60*h)mod(60). Similarly, viable substitutions for flr(h) are, h-frac(h), h-(60*h)mod(60).

These things said, the algorithm in black becomes,

h hrs = flr(h) hrs, 60*(frac(h)) min.

Regards,

Rich B.

3. ## Hi

Originally Posted by psylencer
K, I can do it on paper but how do I get a peice of software like excel
to convert 1.3 hours to 1hr 18min or 01:18?

Any help?
I do not think it would be possible to place the value 1 and 18 in the same box but I am certain I have a method where they can be placed in side to side boxes e.g 1 in one box and 18 in the next box on the right hand side.

Let me know if this fulfils your requirements.
No doubt someon else will have a better method.

4. Originally Posted by syrivaci
I do not think it would be possible to place the value 1 and 18 in the same box but I am certain I have a method where they can be placed in side to side boxes e.g 1 in one box and 18 in the next box on the right hand side.

Let me know if this fulfils your requirements.
No doubt someon else will have a better method.
The TIME function can be used to put the 1 and 18 into a time value. Then that value can be formatted to produce 01:18.

5. ## Hehe

Originally Posted by JakeD
The TIME function can be used to put the 1 and 18 into a time value. Then that value can be formatted to produce 01:18.
I told you someone would come up with a way.
I have a feeling some people on this forum are related to Einstein

6. Originally Posted by syrivaci
I do not think it would be possible to place the value 1 and 18 in the same box but I am certain I have a method where they can be placed in side to side boxes e.g 1 in one box and 18 in the next box on the right hand side.

Let me know if this fulfils your requirements.
No doubt someon else will have a better method.
This would be perferct. Let it be known that excell has an fuction to convert decimal time to Hrs:Min,Secs , but only in 12, or 24 hrs I need some maths to convert 65.3 to 65hrs 18mins.

7. Originally Posted by psylencer
This would be perferct. Let it be known that excell has an fuction to convert decimal time to Hrs:Min,Secs , but only in 12, or 24 hrs I need some maths to convert 65.3 to 65hrs 18mins.
Use this one then. (type the number you want to change in the blue box, ONLY TYPE A NUMBER!)

8. Originally Posted by Rich B.
Hi:

Given input hours=h,

h hrs = floor(h) hrs, 60*(h-floor(h)) min.

Ex.: input: h=1.3
flr(h)=flr(1.3)=1
60*(h-floor(h)) = 60*(1.3 - 1) = 60*0.3 = 18.

Output: 1.3 hrs = 1hr, 18 min.

Notes: (h-floor(h)) is just the "fractional" component, 0.3 in the given example. Substitutions are, therefore, frac(h) and (60*h)mod(60). Similarly, viable substitutions for flr(h) are, h-frac(h), h-(60*h)mod(60).

These things said, the algorithm in black becomes,

h hrs = flr(h) hrs, 60*(frac(h)) min.

Regards,

Rich B.
Excellent work mate! Floor works well. Thanks Heaps. I love nerds!

9. Hi Psylencer:

I am happy to have helped. In all honesty, my programing knowledge is limited. Nonetheless, I am indeed geek enough to help out with the algorithm stuff . In the words of Hewey Lewis, "It's hip to be square" (octagonal is pretty cool too).

Enjoy,

Rich B.