Aaron Bertrand looks at the DATEFROMPARTS function in SQL Server 2012 and later:
The point of these functions is to make it easier to construct a date, or datetime, or datetime2 variable, when you know the individual parts.
DATEFROMPARTS()
takes three arguments:year
,month
, andday
, and returns adate
value. So, for example,SELECT DATEFROMPARTS(2016,7,6);
would yield the date2016-07-06
.
Read on for a comparison of this function against about a dozen other methods of building dates from components.
Comments closed