New DATEFROMPARTS Function in SQL Server 2012

In this article I described new DATEFROMPARTS function in SQL Server 2012.
  • 7216

DATEFROMPARTS Function

The DATEFROMPARTS function is used to return a date value for the specified year, month, and day. The syntax of the DATEFROMPARTS built-in date function is as follows:

DATEFROMPARTS ( year, month, day )

All three parameters of the DATEFROMPARTS function are required.

year: Integer expression specifying a year.
 
month: Integer expression specifying a month, from 1 to 12.

day: Integer expression specifying a day.

Example

Declare @Year as int=2013

Declare @Month as int=02

Declare @Day as int=20

 

Select DATEFROMPARTS(@Year, @Month, @Day)

 

Output

2013-02-20

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.