MySQL DAYNAME() Function
In MySQL, the DAYNAME() function returns the weekday name for a given date.
DAYNAME() Syntax
Here is the syntax of MySQL DAYNAME() function:
DAYNAME(expr)
Parameters
expr- Required. A date or datetime expression.
Return value
The MySQL DAYNAME() function returns the weekday name for a given date, and the return value will be one of the following values: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
- If the specified expression is not a valid date or datetime, the function will return
NULL. - If the argument is
NULL, the function will returnNULL.
DAYNAME() Examples
Here are some examples of the DAYNAME() function.
SELECT
DAYNAME('2022-02-21'),
DAYNAME('2022-02-22'),
DAYNAME('2022-02-23'),
DAYNAME('2022-02-24'),
DAYNAME('2022-02-25'),
DAYNAME('2022-02-26'),
DAYNAME('2022-02-27'),
DAYNAME(NOW()),
DAYNAME('2022-02-00'),
DAYNAME('2022-02-30'),
DAYNAME('Not A DATE'),
DAYNAME(NULL)\G
DAYNAME('2022-02-21'): Monday
DAYNAME('2022-02-22'): Tuesday
DAYNAME('2022-02-23'): Wednesday
DAYNAME('2022-02-24'): Thursday
DAYNAME('2022-02-25'): Friday
DAYNAME('2022-02-26'): Saturday
DAYNAME('2022-02-27'): Sunday
DAYNAME(NOW()): Wednesday
DAYNAME('2022-02-00'): NULL
DAYNAME('2022-02-30'): NULL
DAYNAME('Not A DATE'): NULL
DAYNAME(NULL): NULLTo return today’s weekday name, you can use NOW(), CURDATE(), CURRENT_DATE(), or SYSDATE(). for example:
SELECT
DAYNAME(NOW()),
DAYNAME(CURDATE()),
DAYNAME(CURRENT_DATE()),
DAYNAME(SYSDATE())\G
DAYNAME(NOW()): Wednesday
DAYNAME(CURDATE()): Wednesday
DAYNAME(CURRENT_DATE()): Wednesday
DAYNAME(SYSDATE()): WednesdayNote that your results may be different.