DATEFROMPARTS

DATEFROMPARTS is a SQL function that creates a date value by combining individual parts such as year, month and day.

DATEFROMPARTS(year, month, day);

  • year: Specifies the year portion of the date as an integer.
  • month: Defines the month of the year, represented as an integer from 1 (January) to 12 (December).
  • day: Represents the day of the month as an integer from 1 to 31, in accordance with the specifics of each month.

Example

SELECT DATEFROMPARTS ( 2020, 12, 31 ) AS NewYear;

Output

NewYear
2020-12-31 00:00:00.000

Explanation

In the provided example, the DATEFROMPARTS function is used to create a date from three integer values: the year, the month, and the day. The function thus returns the date ‘2020-12-31’.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.