SQL DATETIMEFROMPARTS

SQL DATETIMEFROMPARTS function is one of the Date and Time Function, which will return a DateTime value from the users specified parts. The basic syntax of the DATETIMEFROMPARTS Function in SQL Server is as follows:

DATETIMEFROMPARTS (year, month, day, hour, minute, seconds, milliseconds)

As you can see from the above DATETIMEFROMPARTS syntax, this function accepts seven arguments to built date and time. This SQL Server function returns DateTime data type value as output.

SQL DATETIMEFROMPARTS Function Example

In this Date and Time Function example, we will show you the use of SQL Server Date time from parts function

-- Example for SQL DATETIMEFROMPARTS Function
SELECT DATETIMEFROMPARTS ( 2017, 12, 19, 10, 09, 18, 503 ) AS Result

SELECT DATETIMEFROMPARTS ( 2017, 12, 19, 10, 09, 18, 0 ) AS Result

SELECT DATETIMEFROMPARTS ( 2017, 12, 19, 00, 00, 18, 503 ) AS Result

-- Let me try the NULL values
SELECT DATETIMEFROMPARTS ( NULL, 12, 19, 00, 00, 18, 503 ) AS Result

SELECT DATETIMEFROMPARTS ( 2017, 12, 19, NULL, 00, 18, 503 ) AS Result
SQL DATETIMEFROMPARTS Function 1