Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql where date is on Monday

Tags:

mysql

I am trying to query MySQL database all the record where date is on Monday or Tuesday like query would be

select count(*) from table where date = Monday;

what would be best way to execute that query in mysql workbench

thanks

like image 691
Sumon Avatar asked Oct 29 '25 01:10

Sumon


1 Answers

Try function weekday:

select count(*) from table where weekday(date) = 0;

And see official doc here.

As @Psi said, if you will concern performance, you should avoid function, and you'd better create a new column to store weeday.

like image 100
Blank Avatar answered Oct 31 '25 14:10

Blank