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
ParameterTypeRequiredDescription
iso8601VARCHARYesAn 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 VARCHARf2 VARCHARf3 VARCHAR
0 days 01:30:001 days 00:00:00423 days 04:05:06

Last update at: 2026/05/26 17:22:09