I\'m looking for something like the person here was lookin for, only I\'d like to use MySQL. The table below is something you\'d find in my database (simplified).
You need to distinguish two cases.
When first < last
, the dates are in the same year. You can then use between
to match dates.
When first > last
, it means last
is in the next year. In this case, the dates that match are date >= first OR date <= last
.
So your WHERE clause should be:
WHERE IF(first < last, @date BETWEEN first AND last,
@date >= first OR date <= last)