- Categories:
PERIOD_ CONSTRUCT¶
Constructs a PERIOD value from a beginning bound and an ending bound of the same temporal element type.
- See also:
Syntax¶
Arguments¶
beginThe inclusive beginning bound. Must be a DATE, TIME, TIMESTAMP_NTZ, TIMESTAMP_LTZ, or TIMESTAMP_TZ value.
endThe 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
beginandendarguments must be temporal values (DATE, TIME, or TIMESTAMP). A VARCHAR argument isn’t implicitly converted and raises an error; cast the string explicitly, for exampleDATE '2024-01-01'or'2024-01-01'::DATE. - If
beginis greater than or equal toend, 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.
Examples¶
This example constructs a PERIOD(DATE) value from two DATE bounds. Because a NULL bound produces a NULL result, the second column returns NULL: