Skip to content

Latest commit

 

History

History
85 lines (62 loc) · 2.55 KB

File metadata and controls

85 lines (62 loc) · 2.55 KB
title DATETIMEFROMPARTS (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 07/29/2017
ms.prod sql
ms.prod_service database-engine, sql-database, sql-data-warehouse, pdw
ms.reviewer
ms.technology t-sql
ms.topic language-reference
f1_keywords
DATETIMEFROMPARTS_TSQL
DATETIMEFROMPARTS
dev_langs
TSQL
helpviewer_keywords
DATETIMEFROMPARTS function
ms.assetid 6008148b-bf75-4c98-9392-68a89fa0711c
author MikeRayMSFT
ms.author mikeray
monikerRange >=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current

DATETIMEFROMPARTS (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2012-all-md]

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 )  

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 supports remoting to [!INCLUDEssCurrent] servers and above. It will not support remoting to servers that have a version below [!INCLUDEssCurrent].

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)