Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
DATETIMEFROMPARTS (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 datetime value for the specified date and time arguments. For more information about valid ranges, see datetime.
👁 Image
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 raises 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 SQL Server 2012 (11.x) servers and later versions. It isn't remoted to servers running SQL Server 2012 (11.x) and earlier versions.
Examples
SELECT DATETIMEFROMPARTS ( 2010, 12, 31, 23, 59, 59, 0 ) AS Result;
Here's the result set.
2010-12-31 23:59:59.000
Related content
Feedback
Was this page helpful?
