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 & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.