DATETIMEFROMPARTS (Transact-SQL)
Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW)
This function returns a datetime value for the specified date and time arguments.
Transact-SQL syntax conventions
Syntax
DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds )
Note
To view Transact-SQL syntax for SQL Server 2014 (12.x) and earlier versions, see Previous versions 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 SQL Server 2012 (11.x) servers and above. It is not remoted to servers that have a version below SQL Server 2012 (11.x).
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
Váš názor
https://aka.ms/ContentUserFeedback.
Připravujeme: V průběhu roku 2024 budeme postupně vyřazovat problémy z GitHub coby mechanismus zpětné vazby pro obsah a nahrazovat ho novým systémem zpětné vazby. Další informace naleznete v tématu:Odeslat a zobrazit názory pro