WEEKDAY(): Day number of the weekday from 0 to 6

SELECT WEEKDAY('2024-01-01'); # 0
SELECT WEEKDAY('2024-12-31'); # 1
SELECT WEEKDAY('2024-02-31'); # NULL
Syntax
WEEKDAY(date)
Example
SELECT WEEKDAY('2016-09-21')
Output is 2

WEEKDAY() function to get number from 0 to 6 based on Weekday in MySQL

Using CURDATE()

SELECT WEEKDAY(CURDATE())
This will return weekday in number of present ( today's ) date.

CURDATE()

For a invalid date we will get Null as output
SELECT WEEKDAY('2015-02-31')
Output is NULL
DEMO: Select date from Calendar to execute WEEKDAY()
Output of WEEKDAY() function is from 0 to 6,
0 for Monday, 1 for Tuesday .... 6 for Sunday

Yesterday today and tomorrow WEEKDAY()

This query will return WEEKDAY() number of yesterday , today and tomorrow
SELECT WEEKDAY(CURDATE()- INTERVAL 1 DAY) as yesterday,
WEEKDAY(CURDATE()) as today,
WEEKDAY(CURDATE()+ INTERVAL 1 DAY) as tomorrow;

SQL Date WEEK() : Week Number in Year( 0 to 53 ) DAYOFWEEK() : Weekday Number from 1 to 7
SQL txt file for WEEKDAY()
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer