DATETIMEFROMPARTS (Transact-SQL)

**APPLIES TO:** ![yes](media/yes.png)SQL Server (starting with 2012) ![yes](media/yes.png)Azure SQL Database ![yes](media/yes.png)Azure SQL Data Warehouse ![yes](media/yes.png)Parallel Data Warehouse

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 SQL Server 2017 servers and above. It will not support remoting to servers that have a version below SQL Server 2017 SQL Server 2017

Examples

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

Here is the result set.

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

See also

datetime (Transact-SQL)