Read duration text like PT49H30M15S

Turn duration text with H, M and S markers, like PT49H30M15S, into the real duration 49:30:15.

What you'll make

In Excel: PT49H30M15S becomes 49:30:15.

The formula

The formula, with a numbered bracket under each part.
NumberPartWhat it doesResult so far
1TEXTBEFORE(TEXTAFTER(A8,"PT"),"H")/24Takes the hours between PT and H, divided by 24.49:00:00
2TEXTBEFORE(TEXTAFTER(A8,"H"),"M")/1440Adds the minutes between H and M.49:30:00
3TEXTBEFORE(TEXTAFTER(A8,"M"),"S")/86400Adds the seconds between M and S.49:30:15

Excel counts time in days, so each number is divided by the hours, minutes or seconds in a day.

=TEXTBEFORE(TEXTAFTER(A8,"PT"),"H")/24+TEXTBEFORE(TEXTAFTER(A8,"H"),"M")/1440+TEXTBEFORE(TEXTAFTER(A8,"M"),"S")/86400

How to use it

Yellow bar at the top? Click Enable Editing.

  1. See it work. The Example tab shows 20 made-up examples with the formula already in.
  2. Use your own durations. Paste duration text like PT49H30M15S into the green column of the Template tab. The durations fill in by themselves.
  3. Move them into your letter. Copy the results. Then use Paste Special and choose Values.

Before you send

Each row needs hours, minutes and seconds, even zeros, like PT1H30M0S. Text with days, like P1DT2H, turns amber.

Microsoft's help: TEXTBEFORE function