Convert minutes into hours

Meeting place for R&R customers and clients to share tips and ideas. Post your questions, messages or problems here.
Post Reply
happydermis
Posts: 63
Joined: Tue Oct 10, 2017 12:44 pm

Convert minutes into hours

Post by happydermis » Fri Dec 10, 2004 3:18 pm

Hi all,____Is there an elegant way to calculate Minutes into hours? I have a column with construction time (in minutes) that I add up. In the end I get a number like 606 Minutes and I would like to convert this number into hours. So far I was simply deviding by 60 and got the decimal representation of the number of hours in 606 Minutes (10,1 hours). Instead I would like to have a time presentation like hh:mm => 10:06.____Thanks, Dekers

Rick_Johnson_(Guest)
Posts: 35
Joined: Tue Oct 10, 2017 12:44 pm

=> RE: Convert minutes into hours

Post by Rick_Johnson_(Guest) » Fri Dec 10, 2004 5:22 pm

There must be several ways, but here is one way. If xxxx is the total minutes:____This will say "125 minutes is 2 hours and 5 minutes" for xxxx = 125____This works because of the MOD function gives the remainder when division occurs, so we use a MOD of 60 to get the minutes. ____str(xxxx,4,0) + " minutes is" + str(xxxx/60,4,0) +" hours and " + str(mod(xxxx,60),2,2) + "minutes"

aqarugubofato
Posts: 0
Joined: Mon Apr 16, 2018 1:52 am

==> RE: Convert minutes into hours

Post by aqarugubofato » Tue Dec 14, 2004 11:30 am

Hi Rick!__Thanks for your quick answer____I did imply your idea and found two flaws in it (but it did help me!):__1. When I use: str(xxxx/60,4,0) with a number, which deivides to a number with a decimal figure that is greater than 0,5 - R&R rounds the number up so for example if I calculate 30/60 I get the number 1 instead of the number 0 for the hours^ position. ____2. By using str(mod(xxxx,60),2,2) for the minutes calculation I get only on minuts^ posiotion in case that the minutes count is less than 10. For example instead of getting "x:06" (x stands for the minutes from section 1) I get- "x: 6".__Can you think of a way to get a "normal" time format like 20:03 or 166:01 ?? ____Many thanks, Dekers____

Rick_Johnson_(Guest)
Posts: 35
Joined: Tue Oct 10, 2017 12:44 pm

===> RE: Convert minutes into hours

Post by Rick_Johnson_(Guest) » Tue Dec 14, 2004 4:10 pm

Rereading your original post, I see the problem i created. Here is how to do it correctly.____Let Timer be the time in minutes ( ex 125)__Create these calculated variables:____C_hours: str(abs(timer/60),6,0) __ && Time in chr hours (2)____N_minutes: mod(timer,60) __ && time in numeric minutes (5)____C_minutes: iif(N_minutes<10, "0" + str(N_minutes,1,0), str(n_minutes,2,0)) __ && Determines if minutes < 10 (05)____Put it together to get the desired experssion:____C_hours + ":" + C_minutes __ &&(2:05)____Best of luck.....

happydermis
Posts: 63
Joined: Tue Oct 10, 2017 12:44 pm

====> RE: Convert minutes into hours

Post by happydermis » Thu Dec 16, 2004 11:51 am

Thanks Rick,____I also found another method :-)__I kept the hours and minutes apart (each in its own field) than I formated the minutes-field with "leading zeros" and two integers. The ":" I get with the help of a simple text box. This way I calculate each figure seperatly and put it all together in the end.____Example: |hours| |:| |minutes|__If the minutes are less than 10 - R&R simply adds a zero befor the digit...____I find this thread a very good one - I think it will serve others in the future and this is exactly the point of froums. ____Thank you very much - you^ve put me on the right track! :-)__Dekers

Post Reply