Skip to content

Latest commit

 

History

History
84 lines (60 loc) · 2.54 KB

File metadata and controls

84 lines (60 loc) · 2.54 KB
title DATETIMEFROMPARTS (Transact-SQL)
description DATETIMEFROMPARTS (Transact-SQL)
author markingmyname
ms.author maghan
ms.date 01/29/2021
ms.prod sql
ms.technology t-sql
ms.topic reference
f1_keywords
DATETIMEFROMPARTS_TSQL
DATETIMEFROMPARTS
helpviewer_keywords
DATETIMEFROMPARTS function
dev_langs
TSQL
monikerRange >= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current

DATETIMEFROMPARTS (Transact-SQL)

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

This function returns a datetime value for the specified date and time arguments.

Topic link icon Transact-SQL Syntax Conventions

Syntax

DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds )  

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

Arguments

year
An integer expression that specifies a year.

month
An integer expression that specifies a month.

day
An integer expression that specifies a day.

hour
An integer expression that specifies hours.

minute
An integer expression that specifies minutes.

seconds
An integer expression that specifies seconds.

milliseconds
An integer expression that specifies milliseconds.

Return types

datetime

Remarks

DATETIMEFROMPARTS returns a fully initialized datetime value. DATETIMEFROMPARTS will raise an error if at least one required argument has an invalid value. DATETIMEFROMPARTS returns null if at least one required argument has a null value.

This function is capable of being remoted to [!INCLUDEsssql11-md] servers and above. It is not remoted to servers that have a version below [!INCLUDEsssql11-md].

Examples

SELECT DATETIMEFROMPARTS ( 2010, 12, 31, 23, 59, 59, 0 ) AS Result;  

[!INCLUDEssResult]

Result  
---------------------------  
2010-12-31 23:59:59.000  
  
(1 row(s) affected)  

See also

datetime (Transact-SQL)