Search code examples
mysqldayofweek

MySql : How to select records based on current week?


How can i select record in a days range based on the current week, example : I want to select all records in rage on current Sunday to Saturday

This below works very well but only for a Monday to Sunday week and I want to do the same for Sunday to Saturday week

WHERE  YEARWEEK(`date`, 1) = YEARWEEK(CURDATE(), 1)

Solution

  • According to https://www.w3schools.com/sql/func_mysql_yearweek.asp you should use:

    WHERE  YEARWEEK(`date`, 0) = YEARWEEK(CURDATE(), 0)