Skip to content
Related Articles

Related Articles

Improve Article
Use of DAYOFWEEK() function in MySQL
  • Last Updated : 10 Dec, 2020

DAYOFWEEK() :
This function in MySQL helps to return weekday numbers/index from the given date(a number from 1 to 7). The weekday index returned by DAYOFWEEK() function follows ODBC standards.

Note –
Following are the weekday numbers.

Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

Syntax :

DAYOFWEEK(date)

Parameters :
The function accepts only one argument.

  • date –
    A DATE or DATETIME from which weekday index is returned

Returns :



  • The function will return weekday numbers/index from the given date(a number from 1 to 7).
  • If the date is zero (0000-00-00) or invalid, in that case, the function will return NULL.

Example-1 :
Obtaining the day of the week from a specific date “2020-09-13”.

SELECT DAYOFWEEK("2020-09-13") 
AS WEEKDAY;

Output :

WEEKDAY
1

Example-2 :
Obtaining the day of the week from a specific DateTime “2000-11-27 07:12:23”.

SELECT DAYOFWEEK("2000-11-02 07:12:23") 
AS WEEKDAY;

Output :

WEEKDAY
5

Example-3 :
Obtaining the day of the week for the current system date i.e using CURDATE() function

SELECT DAYOFWEEK(CURDATE()) 
AS WEEKDAY;

Output :

WEEKDAY
4
My Personal Notes arrow_drop_up
Recommended Articles
Page :