New DATETIMEFROMPARTS Function in SQL Server 2012
In this article I have described new DATETIMEFROMPARTS function in SQL Server 2012.
DATETIMEFROMPARTS Function
The DATETIMEFROMPARTS function is used to return a DateTime value for the specified date and time. The syntax of the DATETIMEFROMPARTS built-in date function is as follows:
DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds )
If the arguments are invalid, then an error is raised. If any of the parameters are null, null is returned.
Example
Declare @Year as int=2013
Declare @Month as int=12
Declare @Day as int=20
Declare @hour as int=58
Declare @minute as int=46
Declare @seconds as int=0
Declare @milliseconds as int=0
Select DATETIMEFROMPARTS (@Year, @Month, @Day, @hour , @minute , @seconds, @milliseconds)
Output
2013-12-20 58:59:46.0000000