DAYOFWEEK() function :
This function in MySQL is used to return the weekday index for a specified date (a number from 1 to 7).
Note : 1=Sunday, 2=Monday, 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday, 7=Saturday.
Syntax :
DAYOFWEEK(date)Parameter : This method accepts a parameter which is illustrated below :
- date - Specified date to return the weekday index from.
SELECT DAYOFWEEK("2020-11-24");
Output :
3Example-2 : Getting the weekday index for a specified date "2020-11-22 07:12:23".
SELECT DAYOFWEEK("2020-11-22 07:12:23");
Output :
1Example-3 : Getting the weekday index for the current system date.
SELECT DAYOFWEEK(CURDATE());Output :
3Application : This function is used to return the weekday index for a specified date (a number from 1 to 7).