Howdy, I have a question on how to do a more variable date query than I can currently do.
I have a database of people which includes information such as their birthday. On my site I want to have a little panel which displays who has a birthday today, sometime in the next week and sometime in the next month.
The birthday variable is stored as a 'date' (YYYY-MM-DD).
Now, for the birthdays "today" my query looks like:
Code:
SELECT * FROM people WHERE month(birth) = '$tm' AND day(birth) = '$td'
where $tm and $td are today's month and day, respectively.
My problem arises when I'm trying to do my over the next week and month query. If I do:
Code:
SELECT * FROM people WHERE (month(birth) BETWEEN '$tm' AND '$wm') AND (day(birth) BETWEEN '$td' AND '$wd')
where $wm and $wd are the month and day of a week from today, respectively - if I do it like this then when it wraps around to a new month it'll check early days in the first month and later days in the second month.
Is there some way to do a query for a date like:
Code:
SELECT * FROM people WHERE birth BETWEEN '????-MM-DD' AND '????-MM-DD'
or somehow get MySQL to ignore the year attached to the date?