This tutorial explains how to use the MySQL DAYOFWEEK function with syntax and examples.
The MySQL DAYOFWEEK function returns the weekday index for a date value.
The syntax for the DAYOFWEEK function in MySQL is:
DAYOFWEEK( date_value )
The date or datetime value from which to extract the day of the week.
The DAYOFWEEK function can be used in the following versions of MySQL:
Let's look at some MySQL DAYOFWEEK function examples and explore how to use the DAYOFWEEK function in MySQL.
For example:
mysql> SELECT DAYOFWEEK('2014-01-27');
Output: 2
mysql> SELECT DAYOFWEEK('2014-01-28');
Output: 3
mysql> SELECT DAYOFWEEK('2014-01-29');
Output: 4
This last DAYOFWEEK example would display the weekday index for the current system date (current system date is returned by the CURDATE function).
mysql> SELECT DAYOFWEEK(CURDATE());