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
SELECT WEEKDAY(CURDATE())
This will return weekday in number of present ( today's ) date.
For a invalid date we will get Null as output
SELECT WEEKDAY('2015-02-31')
Output is NULL
SELECT WEEKDAY(CURDATE()- INTERVAL 1 DAY) as yesterday,
WEEKDAY(CURDATE()) as today,
WEEKDAY(CURDATE()+ INTERVAL 1 DAY) as tomorrow;
Author
🎥 Join me live on YouTubePassionate 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.