Mysql query by weekday


I want to query by weekday in a given table on a column storing dates. E.g. select * from MY_TABLE where date_column is 'Monday'

I saw a DAYOFWEEK() function in mysql. But this only seems to manipulate the results of the query.

So is such a query even possible?


Use weekday name:

FROM my_table 
WHERE DATE_FORMAT(date_column, '%W') = 'Monday';

Use weekday index:

FROM my_table 
WHERE DAYOFWEEK(date_column) = 2 
-- WHERE WEEKDAY(date_column) = 0

Answered By – Akina

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published