SMALLDATETIMEFROMPARTS
creates a smalldatetime 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 smalldatetime from the specified dateparts.
SELECT SMALLDATETIMEFROMPARTS(2022, 9, 28, 11, 54)
AS SmallDatetime
SmallDatetime |
---|
2022-09-28 11:54:00 |
Syntax of the SMALLDATETIMEFROMPARTS function .
SMALLDATETIMEFROMPARTS(year, month, day, hour, minute)
year
-- an integer specifying year.
month
-- an integer specifying month from 1 to 12.
day
-- an integer specifying day of the month.
hour
-- an integer specifying the hour.
minute
-- an integer specifying the minute.
Note: DATETIMEFROMPARTS
will return an error if any of the 5 arguments is invalid.
If any of the arguments is null, then the return value will also be null.