DATEFROMPARTS
Function
Returns a string formatted like "2015-12-25" based on the provided year, month, and day values.
Syntax
DATEFROMPARTS(year, month, day)
Parameters
- year: integer
Four-digit year. - month: integer (1-12)
Calendar month specified as a 1-based integer. - day: integer (1-31)
Day of the month specified as a 1-based integer.
Return Value
A string formatted like "2015-12-25". An error is raised if the arguments do not specify a valid date.Example
PRINT DATEFROMPARTS(2015, 1, 2); -- "2015-01-02"
-- Raises an error because there is no February 31, 2021.
PRINT DATEFROMPARTS(2021, 2, 31);