SQL DATEFROMPARTS function will return a date value from the users specified parts. The basic syntax of the DATEFROMPARTS Function is as follows:
DATEFROMPARTS (year, month, day)
SQL DATEFROMPARTS Function Example
In this DateTime example, we will show you the use the Date from parts.
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 month. Let me show you the result