MySQL select all entries between two dates regardless of year

 

Questions


I need to find all rows in a MySQL database that fall between “YYYY-10-30” and “YYYY-12-11” I don’t care about which year the the date is in just that falls between the two dates.

 

 

————————————————-

Answer

SELECT *
FROM yourTable
WHERE (MONTH(yourDate) = 10 AND DAYOFMONTH(yourDate) >= 30)
   OR (MONTH(yourDate) = 11)
   OR (MONTH(yourDate) = 12 AND DAYOFMONTH(yourDate) <= 11)

database,date,mysql,sql

Leave a Reply

Your email address will not be published. Required fields are marked *