Formula to convert hours mins to number

mrwad

New Member
Joined
Oct 16, 2018
Messages
49
I use formula to display 3 hours 7 mins as 3,7. However formula does not work correctly as it should be 3,07 also the are problems with , and . depending on Excel version.


I don't need it to be 3,07 or 3,7. I need formula to round it to either 3,5 or 4. So if it is 3,07 then it should be 3,5. Basically condition is if mins or min is less than 30 then it is ,5 if more than 30 then next ,0 Then this formula should give as a result 35 and divide it by 10. So for example 35/10 or 40/10. Then there will be no problem with , and . in different Excel versions.


NOTE! Value in P96 comes from Google Maps API xml and shows travelling hours from one location to another. Sometimes there is 3 hours 7 mins, 20 hours 37 mins and sometimes 1 hour 1 min


Current solution:


Code:
    =SUBSTITUTE(CEILING(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(ISERROR(SEARCH("hour", P96)), "0 hours ", "")&P96,"s","")," min","")," hour ","."),0.1), ".", ",")

Asked also here: https://stackoverflow.com/questions/56018465
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi, some examples of the inputs and expected results would help - but in lieu of that, here is an option you can try:


Excel 2013/2016
AB
13 hours 7 mins3.5
21 hour 1 min1.5
31 hour 31 mins2
45 hours 29 mins5.5
510 mins0.5
635 mins1
Sheet1
Cell Formulas
RangeFormula
B1=CEILING(IF(ISERROR(SEARCH("hour",A1)),"0:","")&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"s",""),"hour",":"),"min","")*24,0.5)
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top