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