SQL DATETIMEFROMPARTS

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

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

As you can see from the above syntax, it accepts seven arguments to build date and time. This method returns the DateTime data type value as output.

SQL DATETIMEFROMPARTS Function Example

In this Date and Time example, we will show you the use of SQL Server Date time from parts 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

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.