DATEFROMPARTS
returns the date from the dateparts.
The specified dateparts include year, month, and day.
All three parameters are required.
This example returns a date from the year, month, and day dateparts.
SELECT DATEFROMPARTS(2021, 9, 28) AS 'Returned Date'
Returned Date |
---|
2021-09-28 |
Syntax of the DATEFROMPARTS function.
DATEFROMPARTS(year, month, day)
year
-- an integer specifying year (4 digits).
month
-- an integer specifying month (1 - 12).
day
-- an integer specifying day of month (1 - 31).
Note: DATEFROMPARTS
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.