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]] or PnW, where each component is optional
PnWis n weeks (7 days). ISO 8601 does not combineWwithY,M, orD- Examples: 'PT30M' (30 minutes), 'P1DT12H' (1 day 12 hours), 'P1W' (7 days), '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
Availability
| Status | Backends |
|---|---|
| Not available | mysql |
Examples
FeatureQL
RETURN
-- Parse 1 hour 30 minutes
f1 := FROM_ISO8601_INTERVAL('PT1H30M'),
-- Parse 1 day
f2 := FROM_ISO8601_INTERVAL('P1D'),
-- Parse full ISO 8601 duration
f3 := FROM_ISO8601_INTERVAL('P1Y2M3DT4H5M6S')
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| PT1H30M | P1D | P1Y2M3DT4H5M6S |
On this page