Retrieve the index representing the weekday for a given date.
SELECT DAYOFWEEK(“2017-06-15”); |
The DAYOFWEEK() function retrieves the weekday index for a specified date, represented as a number ranging from 1 to 7.
Note: 1 corresponds to Sunday, 2 to Monday, 3 to Tuesday, 4 to Wednesday, 5 to Thursday, 6 to Friday, and 7 to Saturday.
DAYOFWEEK(date) |
Parameter |
Description |
date |
Necessary. Specify the date from which to retrieve the weekday index. |
Works in: |
From MySQL version 4.0 |
Retrieve the index representing the weekday for a given date.
SELECT DAYOFWEEK(“2017-06-15 09:34:21”); |
Retrieve the index representing the weekday for the current system date.
SELECT DAYOFWEEK(CURDATE()); |