

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Convert ISO 8601 duration string to seconds
I'm loading data that is formatted as ISO 8601 duration string. Below are some samples from the data set.
Each string always starts with "P," which designates Period, and "T" which designates Time. The rest of the string may contain H (Hours), M (Minutes) or S (Seconds) along with numbers for each time element.
For example, the string "PT1H3M11.312S" represents 1 hour, 3 minutes, 11.312 seconds, which translates to 3791 seconds.
Question: is there a script function that will convert an ISO 8601 duration string to seconds?
I'm hoping there is a function so that I won't have to parse out the time elements individually.
Samples from my data:
inboundTalkTime |
PT0S |
PT1H3M11.312S |
PT1H10M21.892S |
PT1H15M56.944S |
PT1H20M7.027S |
PT1H39M18.652S |
PT1H49M33.105S |
PT18M15.285S |
PT42M38.344S |
PT54M0.343S |
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you need to reuse the expression it would be better defined as a variable-that-takes-parameters (function):

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't give you a single function - but maybe a single expression might do the trick:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you need to reuse the expression it would be better defined as a variable-that-takes-parameters (function):


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Peter. That's worked perfectly.
