SQL SMALL DATETIME FROM PARTS function is one of the Date and Time Functions, which will return a small date and time value from the users specified parts. The basic syntax of the SMALL DATETIME FROM PARTS Function is as follows:
SMALLDATETIMEFROMPARTS (year, month, day, hour, minute)
SQL SMALL DATETIME FROM PARTS Function Example
In this example, we will show you the use of the SQL Server SmallDateTimefromParts function. It will also explain what will happen if you pass NULL values or invalid arguments to this function.
-- Example SELECT SMALLDATETIMEFROMPARTS ( 2017, 11, 19, 11, 35 ) AS Result SELECT SMALLDATETIMEFROMPARTS ( 2017, 11, 19, 00, 35 ) AS Result SELECT SMALLDATETIMEFROMPARTS ( 2017, 11, 19, 00, 00 ) AS Result -- Let me try the NULL values SELECT SMALLDATETIMEFROMPARTS ( NULL, 11, 19, 11, 35 ) AS Result -- Feb 2016 is a Leap year SELECT SMALLDATETIMEFROMPARTS ( 2016, 02, 29, 19, 11) AS Result -- Feb 2014 is not a leap year. So, Invalid Argument 29 SELECT SMALLDATETIMEFROMPARTS ( 2014, 02, 29, 19, 11) AS Result
The last statement is throwing an error. Let me show you the Date and Time Function result.