Period functions¶
Snowflake provides scalar functions for constructing, inspecting, comparing, and combining
PERIOD values. PERIOD values are half-open
ranges [begin, end): the beginning bound is inclusive and the ending bound is exclusive.
Unless noted otherwise:
- Both PERIOD arguments must have the same element type (for example, both PERIOD(DATE)).
- A NULL input produces a NULL result.
- Predicate functions return BOOLEAN.
- Set-operation functions return PERIOD (or NULL when the result would be empty).
Constructor and accessors¶
Boolean predicates¶
Set operations¶
Examples¶
Because PERIOD values are half-open, two back-to-back periods meet without overlapping. The earlier period doesn’t contain the shared boundary instant (its exclusive ending bound), but the later period does (its inclusive beginning bound):
For a full table-based walkthrough that stores, queries, orders, and combines PERIOD values, see Examples for the PERIOD data type.
List of functions¶
| Function | Description |
|---|---|
| PERIOD_BEGIN | Returns the inclusive beginning bound of a PERIOD. |
| PERIOD_CONSTRUCT | Builds a PERIOD from beginning and ending temporal values. |
| PERIOD_CONTAINS | Tests whether a PERIOD contains another PERIOD or a temporal instant. |
| PERIOD_END | Returns the exclusive ending bound of a PERIOD. |
| PERIOD_EQUALS | Tests whether two PERIOD values have the same bounds. |
| PERIOD_IMMEDIATELY_PRECEDES | Tests whether the first PERIOD ends exactly where the second begins. |
| PERIOD_IMMEDIATELY_SUCCEEDS | Tests whether the first PERIOD begins exactly where the second ends. |
| PERIOD_INTERSECT | Returns the overlapping sub-range of two PERIOD values, or NULL if disjoint. |
| PERIOD_LDIFF | Returns the portion of the first PERIOD before the second begins, or NULL. |
| PERIOD_MEETS | Tests whether two PERIOD values are adjacent in either order. |
| PERIOD_OVERLAPS | Tests whether two PERIOD values share any instant. |
| PERIOD_PRECEDES | Tests whether the first PERIOD ends at or before the second begins. |
| PERIOD_RDIFF | Returns the portion of the first PERIOD after the second ends, or NULL. |
| PERIOD_SUCCEEDS | Tests whether the first PERIOD begins at or after the second ends. |