DAYNAME
Description
The DAYNAME function is used to calculate the name of the day (such as "Tuesday", etc.) corresponding to a date or time expression, returning a string type value.
This function behaves consistently with the dayname function in MySQL
Syntax
DAYNAME(<date_or_time_expr>)
Parameters
Parameter | Description |
---|---|
<date_or_time_expr> | A valid date expression that supports date/datetime types and strings in date-time format. For specific datetime and date formats, please refer to datetime conversion and date conversion |
Return Value
Returns the day name corresponding to the date (string type)
Special cases:
- If
date_or_time_expr
is NULL, returns NULL;
Examples
---Calculate day name corresponding to DATETIME type
select dayname('2007-02-03 00:00:00');
+--------------------------------+
| dayname('2007-02-03 00:00:00') |
+--------------------------------+
| Saturday |
+--------------------------------+
---Calculate day name corresponding to DATE type
select dayname('2023-10-01');
+-----------------------+
| dayname('2023-10-01') |
+-----------------------+
| Sunday |
+-----------------------+
---Parameter is NULL, returns NULL
select dayname(NULL);
+---------------+
| dayname(NULL) |
+---------------+
| NULL |
+---------------+