Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

DATEFROMPARTS (Transact-SQL)

Applies to: 👁 Image
SQL Server 👁 Image
Azure SQL Database 👁 Image
Azure SQL Managed Instance 👁 Image
Azure Synapse Analytics 👁 Image
Analytics Platform System (PDW) 👁 Image
SQL database in Microsoft Fabric

This function returns a date value that maps to the specified year, month, and day values.

👁 Image
Transact-SQL syntax conventions

Syntax

DATEFROMPARTS ( year, month, day ) 

Arguments

year
An integer expression that specifies a year.

month
An integer expression that specifies a month, from 1 to 12.

day
An integer expression that specifies a day.

Return types

date

Remarks

DATEFROMPARTS returns a date value, with the date portion set to the specified year, month and day, and the time portion set to the default. For invalid arguments, DATEFROMPARTS will raise an error. DATEFROMPARTS returns null if at least one required argument has a null value.

This function can handle remoting to SQL Server 2012 (11.x) servers and above. It cannot handle remoting to servers with a version below SQL Server 2012 (11.x).

Examples

This example shows the DATEFROMPARTS function in action.

SELECT DATEFROMPARTS ( 2010, 12, 31 ) AS Result; 

Here's the result set.

Result 
---------------------------------- 
2010-12-31 
 
(1 row(s) affected) 

See also

date (Transact-SQL)


Feedback

Was this page helpful?

Additional resources