"Pooly" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
Hi,

I would like to display a list of members who have their birthday a
given day (today for instance).
My idea is to store their birth date in a column, and then query the
table against the column. But the query would be like :
select id from members where MONTH(birthday) = MONTH(NOW()) AND
DAY(birthday)=DAY(NOW())
but it would perform a entire table scan with that.
What would be your best strategy for that sort of query ?
And how would you deal with 29th of february ?

You could store a special-birthday-date, which forces the year to a known 
value (like 2000).  So, everyone's "specialdate" field would be in the range 
1-1-2000 (0:0:0 o'clock) to 12-31-2000 (23:59:59 o'clock).

Then, you could do a simple range comparison:
specialdate >= begin-today AND specialdate <= end-today.
This would also allow you to easily display weekend birthdays on Friday 
(have the end-date be midnight on Sunday).

DanB




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to