PERIOD_CONSTRUCT
functionsupportedCore SQL functionsConstructs a PERIOD value from a beginning bound and an ending bound of the same temporal element type.
Syntax
PERIOD_CONSTRUCT( <begin>, <end> )
Parameters
| Name | Required | Description |
|---|---|---|
begin | required | The inclusive beginning bound. Must be a DATE, TIME, TIMESTAMP_NTZ, TIMESTAMP_LTZ, or TIMESTAMP_TZ value. |
end | required | The exclusive ending bound. Must have the same logical type as begin. |
Returns
A PERIOD value whose element type matches the type of the input bounds. For TIME and TIMESTAMP inputs, the result scale is the maximum of the input scales.
Usage notes
- The begin and end arguments must be temporal values (DATE, TIME, or TIMESTAMP). A VARCHAR argument isn’t implicitly converted and raises an error; cast the string explicitly, for example DATE '2024-01-01' or '2024-01-01'::DATE.
- If begin is greater than or equal to end, Snowflake raises an error.
- If either argument is NULL, the function returns NULL.
- To create a PERIOD value from a string instead of two bound expressions, use the typed literal syntax, for example PERIOD(DATE) '[2024-01-01, 2024-12-31)'. For more information, see Typed literal.