I have a MySQL member
table, with a DOB
field which stores all members' dates of birth in DATE
format (Notice: it has the "Year" part)
I'm trying to find the correct SQL to:
- List all birthdays within the next 14 days
and another query to:
- List all birthdays within the previous 14 days
Directly comparing the current date by:
(DATEDIFF(DOB, now()) <= 14 and DATEDIFF(DOB, now()) >= 0)
will fetch nothing since the current year and the DOB year is different.
However, transforming the DOB to 'this year' won't work at all, because today could be Jan 1 and the candidate could have a DOB of Dec 31 (or vice versa)
It will be great if you can give a hand to help, many thanks! :)