Name

DAYOFWEEK( )

Synopsis

DAYOFWEEK(date)

This function returns numerical day of the week for a given date. Sunday returns a value of 1, and Saturday returns a value of 7.

SELECT DAYOFWEEK('2005-03-01')
          AS 'Day of Week',
       DAYNAME('2005-03-01')
          AS 'Name of Day';
+-------------+-------------+
| Day of Week | Name of Day |
+-------------+-------------+
|           3 | Tuesday     |
+-------------+-------------+

In this example, the date is on the third day of the week, which is a Tuesday.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.