Skip to content

Latest commit

 

History

History
73 lines (53 loc) · 2.29 KB

datefromparts-transact-sql.md

File metadata and controls

73 lines (53 loc) · 2.29 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs monikerRange
DATEFROMPARTS (Transact-SQL)
DATEFROMPARTS (Transact-SQL)
markingmyname
maghan
07/29/2017
sql
t-sql
reference
DATEFROMPARTS_TSQL
DATEFROMPARTS
DATEFROMPARTS function
TSQL
>= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current

DATEFROMPARTS (Transact-SQL)

[!INCLUDE sql-asdb-asdbmi-asa-pdw]

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

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

DATEFROMPARTS ( year, month, day )  

[!INCLUDEsql-server-tsql-previous-offline-documentation]

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 [!INCLUDEssSQL11] servers and above. It cannot handle remoting to servers with a version below [!INCLUDEssSQL11].

Examples

This example shows the DATEFROMPARTS function in action.

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

[!INCLUDEssResult]

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

See also

date (Transact-SQL)