Nóta
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as shíniú isteach nó eolairí a athrú.
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as eolairí a athrú.
Applies to:
Databricks SQL
Databricks Runtime
Creates a date from year, month, and day fields.
Syntax
make_date(year, month, day)
Arguments
year: An INTEGER expression evaluating to a value from 1 to 9999.month: An INTEGER expression evaluating to a value from 1 (January) to 12 (December).day: An INTEGER expression evaluating to a value from 1 to 31.
Returns
A DATE.
In Databricks SQL, if any of the arguments is out of bounds, the result is NULL.
In Databricks Runtime, if any of the arguments are out of bounds, Azure Databricks raises DATETIME_FIELD_OUT_OF_BOUNDS unless spark.sql.ansi.enabled is false, in which case the function returns NULL.
Common error conditions
Examples
> SELECT make_date(2013, 7, 15);
2013-07-15
> SELECT make_date(2019, 13, 1);
NULL
> SELECT make_date(2019, 7, NULL);
NULL
> SELECT make_date(2019, 2, 30);
NULL
-- In DBR with ANSI mode, out-of-bounds fields raise an error.
> SELECT make_date(2024, 13, 1);
Error: DATETIME_FIELD_OUT_OF_BOUNDS