Skip to content

DAYOFWEEK

  • date: This parameter is the date from which the day of the week is to be returned. The date must be in a format that MySQL can recognize, such as ‘YYYY-MM-DD’ or ‘DD-MM-YYYY’. The function will return a number ranging from 1 (for Sunday) to 7 (for Saturday).
SELECT DAYOFWEEK('2021-10-30') AS DayOfWeek;
+-----------+
| DayOfWeek |
+-----------+
| 7 |
+-----------+

The DAYOFWEEK function in MySQL returns the weekday index for a given date, where 1 represents Sunday and 7 represents Saturday. In this case, the function has returned the value 7, indicating that October 30, 2021, is a Saturday.