- Categories:
DATE_FROM_PARTS¶
Creates a date from individual numeric components that represent the year, month, and day of the month.
- Aliases:
DATEFROMPARTS
Syntax¶
Arguments¶
yearThe integer expression to use as a year for building a date.
monthThe integer expression to use as a month for building a date, with January represented as 1, and December as 12.
dayThe integer expression to use as a day for building a date, usually in the 1-31 range.
Usage notes¶
DATE_FROM_PARTS is typically used to handle values in “normal” ranges (e.g. months 1-12, days 1-31), but it also handles values from outside these ranges. This allows, for example, choosing the N-th day in a year, which can be used to simplify some computations.
Year, month, and day values can be negative (e.g. to calculate a date N months prior to a specific date). The behavior of negative numbers is not entirely intuitive; see the Examples section for details.
Examples¶
Components in normal ranges:
Components outside normal ranges:
100th day (from January 1, 2010)
24 months (from January 1, 2010)
Components with zero or negative numbers: