Open In App

DAYOFWEEK() Function in MySQL

Last Updated : 03 Dec, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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.

Returns :
It returns the weekday index for a specified date (a number from 1 to 7).

Example-1 :
Getting the weekday index for a specified date “2020-11-24”.

SELECT DAYOFWEEK("2020-11-24");

Output :

3

Example-2 :
Getting the weekday index for a specified date “2020-11-22 07:12:23”.

SELECT DAYOFWEEK("2020-11-22 07:12:23");

Output :

1

Example-3 :
Getting the weekday index for the current system date.

SELECT DAYOFWEEK(CURDATE());

Output :

3

Application :
This function is used to return the weekday index for a specified date (a number from 1 to 7).


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads