MySQL: DAYNAME Function
This MySQL tutorial explains how to use the MySQL DAYNAME function with syntax and examples.
Description
The MySQL DAYNAME function returns the weekday name for a date.
Syntax
The syntax for the DAYNAME function in MySQL is:
DAYNAME( date_value )
Parameters or Arguments
- date_value
- The date or datetime value from which to extract the weekday name.
Note
- The DAYNAME function returns the name of the weekday (Sunday, Monday, Tuesday, etc.) given a date value.
- See also the WEEKDAY function.
Applies To
The DAYNAME function can be used in the following versions of MySQL:
- MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23
Example
Let's look at some MySQL DAYNAME function examples and explore how to use the DAYNAME function in MySQL.
For example:
mysql> SELECT DAYNAME('2014-01-27'); Result: 'Monday' mysql> SELECT DAYNAME('2014-01-28'); Result: 'Tuesday' mysql> SELECT DAYNAME('2014-01-29 08:35:17'); Result: 'Wednesday'
This last DAYNAME example would display the weekday name for the current system date (current system date is returned by the CURDATE function).
mysql> SELECT DAYNAME(CURDATE());
Advertisements