PARSE_DURATION
All functions > DATE_AND_TIME > PARSE_DURATION
Returns an interval from the given duration string.
Syntax
PARSE_DURATION(duration)
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
duration | VARCHAR | Yes | A duration string to parse (e.g., '1 day', '2 hours') |
Returns
An INTERVAL value representing the duration
Notes
- Parses duration strings into INTERVAL values
- Supports formats like '1 day', '2 hours 30 minutes', '3 months'
- Useful for creating intervals from string representations
- Common units: seconds, minutes, hours, days, weeks, months, years
- Can combine multiple units in a single string