Get time More than 24 Hours correctly

Sufiyan97

Well-known Member
Joined
Apr 12, 2019
Messages
1,619
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
I have data as below, formula works fine except for greater or equal to 24 hours

How to get correct time if it is greater or equal to 24 hours

Book1
ABC
1Time Tracked TextTime
24 h 15 m4:15:00
315 m0:15:00
415 m0:15:00
53 h 30 m3:30:00
62 h 15 m2:15:00
745 h 21:00:00
844 h20:00:00
925 h1:00:00
1024 h0:00:00
11
12
Sheet1
Cell Formulas
RangeFormula
B2:B10B2=IF(ISNUMBER(SEARCH("h",A2)),TIMEVALUE(SUBSTITUTE(SUBSTITUTE(A2," h",":")," m",":00")),TIMEVALUE("00:"&SUBSTITUTE(A2," m",":00")))
 
May be something like this,
Book1
AB
1Time Tracked TextTime
24 h 15 m4:15:00
315 m0:15:00
415 m0:15:00
53 h 30 m3:30:00
62 h 15 m2:15:00
745 h45:00:00
844 h44:00:00
925 h25:00:00
1024 h24:00:00
Sheet4
Cell Formulas
RangeFormula
B2:B10B2=IF(ISNUMBER(SEARCH("h",A2)),TEXT(LEFT(A2,FIND(" h",A2)-1)/24 + IF(ISNUMBER(SEARCH("m",A2)), MID(A2,FIND("h",A2)+2,FIND(" m",A2)-FIND("h",A2)-2)/1440, 0), "[h]:mm:ss"),IF(ISNUMBER(SEARCH("m",A2)),TEXT(LEFT(A2,FIND(" m",A2)-1)/1440, "[h]:mm:ss")," "))
 
Upvote 0
Try using double negation instead of TIMEVALUE and custom-formatting the cell as [h]:mm:ss
Excel Formula:
=IF(ISNUMBER(SEARCH("h",A2)),--(SUBSTITUTE(SUBSTITUTE(A2," h",":")," m",":00")),--("00:"&SUBSTITUTE(A2," m",":00")))
 
Upvote 0
Solution
Another option:
Excel Formula:
=--TEXTJOIN(":",,TEXTSPLIT(A2,{"h","m","s"},,1))
 
Upvote 0
Upvote 0
A huge thank you to everyone! All the solutions worked for the provided data, except for a few cases that weren’t mentioned in the original question.

@Tetra201 @Cubist, your solutions worked for all cases, so I got everything working.

Once again, I really appreciate everyone's help. Thank you!
Cell Formulas
RangeFormula
B2:B14B2=IF(ISNUMBER(SEARCH("h",A2)),--(SUBSTITUTE(SUBSTITUTE(A2," h",":")," m",":00")),--("00:"&SUBSTITUTE(A2," m",":00")))
C2:C14C2=--(IFERROR(TEXTBEFORE(A2," h"),0)&":"&IFERROR(RIGHT(TEXTBEFORE(A2," m"),2),0)&":0")
D2:D14D2=--TEXTJOIN(":",,TEXTSPLIT(IF(ISNUMBER(SEARCH("h",A2)),"","0h")&A2&"0m",{"h","m"}))
E2:E14E2=--IF(ISNUMBER(SEARCH("h",A2)),TEXT(LEFT(A2,FIND(" h",A2)-1)/24 + IF(ISNUMBER(SEARCH("m",A2)), MID(A2,FIND("h",A2)+2,FIND(" m",A2)-FIND("h",A2)-2)/1440, 0), "[h]:mm:ss"),IF(ISNUMBER(SEARCH("m",A2)),TEXT(LEFT(A2,FIND(" m",A2)-1)/1440, "[h]:mm:ss")," "))
 
Upvote 0

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