MySQL WEEKDAY() Function

The WEEKDAY() function in MySQL determines the day of the week for a given date and returns a corresponding integer.



WEEKDAY(): Definition and Usage

This function is helpful when you need to perform operations based on the day of the week, such as filtering data for specific weekdays or generating weekly reports. The numbering of days starts with Monday (0) and ends with Sunday (6).

Syntax

Syntax

WEEKDAY(date)
      

Parameter Values

Parameter Description
date The date or datetime value for which you want to determine the weekday. This is required.

Weekday Numbering

Important Note: WEEKDAY() uses the following numbering scheme:

  • 0: Monday
  • 1: Tuesday
  • 2: Wednesday
  • 3: Thursday
  • 4: Friday
  • 5: Saturday
  • 6: Sunday

Examples

Weekday Number for a Specific Date

This query shows the weekday number for June 15th, 2017.

Syntax

SELECT WEEKDAY("2017-06-15");
      
Output

3  (Thursday)
      

Weekday Number for Another Date

This query shows the weekday number for January 1st, 2017.

Syntax

SELECT WEEKDAY("2017-01-01");
      
Output

0 (Sunday)
      

Weekday Number for the Current Date

This query gets the weekday number for today's date.

Syntax

SELECT WEEKDAY(CURDATE());
      
Output

(The weekday number for the current date, 0-6)