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

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);