I need to select all entries between two given dates (Nov 10 and Jan 25, for example) regardless of year.
It’s MUCH easier if it would just be Jan 25 and Nov 10. But how would I structure my query to look for all data between Nov 10 and Jan 25?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use MySQL’s
DAYOFYEAR()function:If
DAYOFYEAR(A)>DAYOFYEAR(B)then your application need either replaceBETWEENwithNOT BETWEENor else swap the order of the arguments. If you need to do it in SQL:Be careful of leap years as the
DAYOFYEAR()function will take those into consideration