ISO 8601 Duration
Duration in ISO 8601 format (PnYnMnDTnHnMnS or PnW for weeks). Used in iCalendar, XML Schema, YouTube API, Google Calendar, and many APIs. Covers both compact (PT30M) and verbose (P1Y2M3DT4H5M6S) forms.
ISO 8601 Duration
datetime.duration.iso_8601Duration in ISO 8601 format (PnYnMnDTnHnMnS or PnW for weeks). Used in iCalendar, XML Schema, YouTube API, Google Calendar, and many APIs. Covers both compact (PT30M) and verbose (P1Y2M3DT4H5M6S) forms.
Domain
datetime
Category
duration
Casts to
INTERVAL
Scope
Universal
Try it
CLI
$ finetype infer -i "PT30M"
→ datetime.duration.iso_8601DuckDB
Detect
SELECT finetype('PT30M');
-- → 'datetime.duration.iso_8601'Cast expression
{col}::INTERVALSafe cast pipeline
-- Normalise and cast in one step
SELECT TRY_CAST(finetype_cast(my_column) AS INTERVAL) AS clean_value
FROM my_table
WHERE finetype(my_column) = 'datetime.duration.iso_8601';JSON Schema
finetype schema datetime.duration.iso_8601
{
"$id": "https://meridian.online/schemas/datetime.duration.iso_8601",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "Duration in ISO 8601 format (PnYnMnDTnHnMnS or PnW for weeks). Used in iCalendar, XML Schema, YouTube API, Google Calendar, and many APIs. Covers both compact (PT30M) and verbose (P1Y2M3DT4H5M6S) forms.",
"examples": [
"PT30M",
"PT1H30M",
"P1DT12H",
"P1Y6M",
"P2W",
"P1Y2M3DT4H5M6S"
],
"pattern": "^-?P(?=\\d|T\\d)(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)[DW])?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+(?:\\.\\d+)?)S)?)?$",
"title": "ISO 8601 Duration",
"type": "string",
"x-finetype-broad-type": "INTERVAL",
"x-finetype-transform": "{col}::INTERVAL"
}Examples
PT30MPT1H30MP1DT12HP1Y6MP2WP1Y2M3DT4H5M6SAliases
durationiso_8601_verbose