FROM_ISO8601_INTERVAL()
All functions > DATE AND TIME > FROM_ISO8601_INTERVAL()
Returns an interval from the given ISO 8601 duration string.
Signatures
Returns: An INTERVAL value representing the duration
FROM_ISO8601_INTERVAL(iso8601: VARCHAR) → INTERVAL sql
| Parameter | Type | Required | Description |
|---|---|---|---|
iso8601 | VARCHAR | Yes | An ISO 8601 duration string (e.g. 'PT1H30M', 'P1Y2M3DT4H5M6S') |
Notes
- Parses ISO 8601 duration strings into INTERVAL values
- Format: P[nY][nM][nD][T[nH][nM][nS]] where each component is optional
- Examples: 'PT30M' (30 minutes), 'P1DT12H' (1 day 12 hours), 'P1Y2M3DT4H5M6S' (full form)
- For verbose duration strings like '2 hours 30 minutes', use INTERVAL_PARSE() instead
- All components default to 0 when omitted; the 'T' separator is required before time components
Examples
FeatureQL
SELECT
f1 := FROM_ISO8601_INTERVAL('PT1H30M'), -- Parse 1 hour 30 minutes
f2 := FROM_ISO8601_INTERVAL('P1D'), -- Parse 1 day
f3 := FROM_ISO8601_INTERVAL('P1Y2M3DT4H5M6S') -- Parse full ISO 8601 duration
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 0 days 01:30:00 | 1 days 00:00:00 | 423 days 04:05:06 |
On this page