Convert TIME from a stupid way of representing into something meaningful

excelsion

New Member
Joined
Jan 18, 2016
Messages
34
Hello,

I have a report where the time taken by a certain activity is reported in the manner below ( not sure what the reporting analyst thought when designing it)....How to I make it workable and calculate the time in hours????
5Hours 11Mins 17Seconds
1Day 3Hours 2Mins 27Seconds
2Days 14Hours 15Mins 38Seconds
2Days 1Hour 51Mins 49Seconds
14Hours 39Mins 2Seconds
10Days 4Hours 38Mins 4Seconds
20Hours 51Mins 8Seconds
11Hours 17Mins 23Seconds

<colgroup><col></colgroup><tbody>
</tbody>
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
you can use a custom function, then format the cells as [h]:mm:ss

Code:
Function ConvertStringToTime(ByVal S As String) As Date
              ConvertStringToTime = Evaluate(Replace(Replace(Replace(Replace(Replace(Replace(S, "s", ""), "Day", "*1"), "Hour", "/24"), "Min", "/1440"), "Second", "/86400"), " ", "+"))
End Function



Excel 2010
PQ
205Hours 11Mins 17Seconds5:11:17
211Day 3Hours 2Mins 27Seconds27:02:27
222Days 14Hours 15Mins 38Seconds62:15:38
232Days 1Hour 51Mins 49Seconds49:51:49
2414Hours 39Mins 2Seconds14:39:02
2510Days 4Hours 38Mins 4Seconds244:38:04
2620Hours 51Mins 8Seconds20:51:08
2711Hours 17Mins 23Seconds11:17:23
Sheet2
Cell Formulas
RangeFormula
Q20=ConvertStringToTime(P20)
Q21=ConvertStringToTime(P21)
Q22=ConvertStringToTime(P22)
Q23=ConvertStringToTime(P23)
Q24=ConvertStringToTime(P24)
Q25=ConvertStringToTime(P25)
Q26=ConvertStringToTime(P26)
Q27=ConvertStringToTime(P27)
 
Upvote 0
This is brilliant...the only challenge is ..its skipping the days and only converting from hours and beyond...


2Days 14Hours 15Mins 38Seconds14:15:38

<tbody>
</tbody>


I copied the exact code in a new module...and ran it.


you can use a custom function, then format the cells as [h]:mm:ss

Code:
Function ConvertStringToTime(ByVal S As String) As Date
              ConvertStringToTime = Evaluate(Replace(Replace(Replace(Replace(Replace(Replace(S, "s", ""), "Day", "*1"), "Hour", "/24"), "Min", "/1440"), "Second", "/86400"), " ", "+"))
End Function


Excel 2010
PQ
205Hours 11Mins 17Seconds5:11:17
211Day 3Hours 2Mins 27Seconds27:02:27
222Days 14Hours 15Mins 38Seconds62:15:38
232Days 1Hour 51Mins 49Seconds49:51:49
2414Hours 39Mins 2Seconds14:39:02
2510Days 4Hours 38Mins 4Seconds244:38:04
2620Hours 51Mins 8Seconds20:51:08
2711Hours 17Mins 23Seconds11:17:23

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
Q20=ConvertStringToTime(P20)
Q21=ConvertStringToTime(P21)
Q22=ConvertStringToTime(P22)
Q23=ConvertStringToTime(P23)
Q24=ConvertStringToTime(P24)
Q25=ConvertStringToTime(P25)
Q26=ConvertStringToTime(P26)
Q27=ConvertStringToTime(P27)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
on my side it is converting days as well,

if in your cell you have:
1Day 3Hours 2Mins 27Seconds

<colgroup><col width="216"></colgroup><tbody>
</tbody>

then it wil be :
27:02:27

<colgroup><col width="73"></colgroup><tbody>
</tbody>

<colgroup><col width="216"></colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,854
Members
449,096
Latest member
Erald

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