SQL DATEFROMPARTS function will return a date value from the user’s specified parts. The basic syntax of the DATEFROMPARTS Function is as follows:
DATEFROMPARTS (year, month, day)
As you can see from the syntax, it accepts three arguments to build a date. This SQL Server method returns the SQL data type date value as output.
SQL DATEFROMPARTS Function Example
In this Date and Time functions example, we will show you the use of the Date from parts. Please refer to the list of SQL Date functions available on our SQL Server Tutorial page.
SELECT DATEFROMPARTS ( 2017, 12, 19) AS Result SELECT DATEFROMPARTS ( 2014, 02, 25) AS Result -- Let me try with Null Values SELECT DATEFROMPARTS ( NULL, 12, 19 ) AS Result SELECT DATEFROMPARTS ( 2017, 12, NULL ) AS Result -- Feb 2016 is a Leap year SELECT DATEFROMPARTS ( 2016, 02, 29) AS Result -- Feb 2014 is not a leap year. So, Invalid Argument 29 SELECT DATEFROMPARTS ( 2014, 02, 29) AS Result

As you can see, the last statement is throwing an error. It is because there is no 29th date in February. Let me show you the result. Please refer to the SQL DATETIMEFROMPARTS, SQL CAST, and SQL CONVERT functions.
