|
Posted by Tyrone Slothrop on 12/18/05 17:45
On Sat, 17 Dec 2005 22:21:17 -0800, gerg <noemail@noemail.com> wrote:
>I'm trying to create a site for my family and one of the features is
>going to be a "birthday" reminder of upcoming birthdays. I'm having
>each member register and in doing so enter their birthday in the
>following format:
>
>04-21-1983 or 11-23-1976
>
>What I want to do is write a script that will check the database from
>the current date, and then go out 30 days to check and see if any
>birthdays lie in that range. I guess I'm just not sure what my query
>should look like.
>
>So, taking today for instance, it's the 17th of Dec. I want to find out
>if there are any birthdays between the 17th of Dec and the 16th of Jan.
>Can anyone help me out with this?
>
>Thanks in advance.
>
>Greg
In MySQL a date would be saved in the format yyyy-mm-dd and, if you
stored the value in that format, the query would be like:
SELECT * FROM table WHERE (birthdate >= CURRENT_DATE() OR birthdate <=
DATE_ADD(CURRENT_DATE(),INTERVAL 30 DAY);
Navigation:
[Reply to this message]
|