INTERVAL_PARSE()
All functions > DATE AND TIME > INTERVAL_PARSE()
Returns an interval from the given duration string.
Signatures
Returns: An INTERVAL value representing the duration
INTERVAL_PARSE(duration: VARCHAR) → INTERVAL sql
| Parameter | Type | Required | Description |
|---|---|---|---|
duration | VARCHAR | Yes | A duration string to parse (e.g., '1 day', '2 hours') |
Notes
- Parses verbose duration strings into INTERVAL values
- Supports formats like '1 day', '2 hours 30 minutes', '3 months'
- Common units: seconds, minutes, hours, days, weeks, months, years
- Can combine multiple units in a single string
- For ISO 8601 duration strings like 'PT1H30M' or 'P1Y2M3DT4H5M6S', use FROM_ISO8601_INTERVAL() instead
Examples
FeatureQL
SELECT
f1 := INTERVAL_PARSE('1 day'), -- Parse 1 day interval
f2 := INTERVAL_PARSE('2 hours 30 minutes'), -- Parse combined interval
f3 := INTERVAL_PARSE('3 months') -- Parse 3 months interval
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 1 days | 2 hours 30 mins | 3 mons |
On this page