DAYOFWEEK

DAYOFWEEK(date)

Returns the day of the week as a number according to the ODBC standard: 1 = Sunday, 2 = Monday … 7 = Saturday.

Parameters

  • date – a DATE or DATETIME value or a string with a date.

Examples

Examples with the customers, products and orders tables use the sample database from the SQL basics series.

SELECT DAYOFWEEK('2026-03-15') AS sunday, DAYOFWEEK('2026-03-16') AS monday, DAYOFWEEK('2026-03-21') AS saturday;
+--------+--------+----------+
| sunday | monday | saturday |
+--------+--------+----------+
|      1 |      2 |        7 |
+--------+--------+----------+

Orders on a weekend:

SELECT id, order_date FROM orders WHERE DAYOFWEEK(order_date) IN (1, 7) ORDER BY id;
+----+------------+
| id | order_date |
+----+------------+
|  6 | 2026-03-01 |
|  7 | 2026-03-15 |
+----+------------+

Things to watch out for

  • The week starts on Sunday. For a week starting on Monday (the ISO week used in most of Europe), WEEKDAY() (0 = Monday) is more convenient.

Related:
WEEKDAY()
DAYNAME()
ELT()