DATETIMEFROMPARTS creates a datetime value.
The returned value is based on the specified datepart arguments.
All arguments are required. If any is null, then null is returned.
This example returns a datetime value from the specified dateparts.
SELECT DATETIMEFROMPARTS(2022, 5, 28, 11, 54, 17, 0)
AS Datetime
| Datetime |
|---|
| 2022-05-28 11:54:17.000 |
Syntax of the DATETIMEFROMPARTS function .
DATETIMEFROMPARTS(year, month, day,
hour, minute, seconds, milliseconds)
year -- an integer specifying year.
month -- an integer specifying month.
day -- an integer specifying day of month.
hour -- an integer specifying the hour.
minute -- an integer specifying the minute.
seconds -- an integer specifying the seconds.
milliseconds -- an integer specifying the milliseconds.
Note: DATETIMEFROMPARTS will return an error if any of the arguments is invalid.
If any of the arguments is null, then the return value will also be null.