DATE_FROM_PARTS
functionsupportedCore SQL functionsCreates a date from individual numeric components that represent the year, month, and day of the month.
Syntax
DATE_FROM_PARTS( <year>, <month>, <day> )
Parameters
| Name | Required | Description |
|---|---|---|
year | required | The integer expression to use as a year for building a date. |
month | required | The integer expression to use as a month for building a date, with January represented as 1, and December as 12. |
day | required | The 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.