weekday
Description
Syntax
INT WEEKDAY (DATETIME date)
The WEEKDAY function returns the index value of the working day of the date, that is, 0 on Monday, 1 on Tuesday, and 6 on Sunday.
The parameter is Date or Datetime type
Notice the difference between WEEKDAY and DAYOFWEEK:
1. +-----+-----+-----+-----+-----+-----+-----+
2. | Sun | Mon | Tues| Wed | Thur| Fri | Sat |
3. +-----+-----+-----+-----+-----+-----+-----+
4. weekday | 6 | 0 | 1 | 2 | 3 | 4 | 5 |
5. +-----+-----+-----+-----+-----+-----+-----+
6. dayofweek | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
7. +-----+-----+-----+-----+-----+-----+-----+
example
1. mysql> select weekday('2019-06-25');
2. +--------------------------------+
3. | weekday('2019-06-25 00:00:00') |
4. +--------------------------------+
5. | 1 |
6. +--------------------------------+
8. mysql> select weekday(cast(20190625 as date));
9. +---------------------------------+
10. | weekday(CAST(20190625 AS DATE)) |
11. +---------------------------------+
12. | 1 |
13. +---------------------------------+
keywords
1. WEEKDAY
