getting the hour number out of string of characters

bartvdg

Board Regular
Joined
Sep 27, 2009
Messages
65
I have some excel data with shows up in this format:
PT1H11M47S

<tbody>
</tbody>

I would like to extract the number before the letter "H", in this example result needs to be 1

I can do this by using two formulas:
=TRIM(SUBSTITUTE(P16;"PT";"")) removes PT ---> 1H11M47S
=LEFT(Q16;VALUE(FIND("H";Q16;1))-1) shows the result ---> 1

I'm not succeeding in merging the 2 formulas, or maybe there is an easier way to do this?
Thanks!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Here are more examples and the desired outcome, your formula only brought one number

Time with AgentHours with Agent
PT1000H11M47S1000
PT53H11M47S53
PT1H11M47S1
PT8M51S0
PT33M27S0

<colgroup><col span="2"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi,

I'd imagine you would want the formula results converted to Real Numbers for further math/comparisons, just add +0 :

=IFERROR(MID(P11;3;FIND("H";P11)-3)+0;0)
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

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