How to find BIRTHDAY FRIENDS Who is celebrating today using PHP and MYSQL
This person is processing February 29 - March 1 treatment as a holiday during off-peak years.
SELECT u.name FROM users u INNER JOIN friendships f ON (f.user_id = u.id) WHERE f.friend_id = 6 -- whatever your id is AND ( MONTH(u.birthdate) = MONTH(NOW()) AND DAY(u.birthdate) = DAY(NOW()) ) OR ( MONTH(c.birthdate) = 2 AND DAY(c.birthdate) = 29 AND MONTH(NOW()) = 3 AND DAY(NOW()) = 1 AND (YEAR(NOW()) % 4 = 0) AND ((YEAR(NOW()) % 100 != 0) OR (YEAR(NOW()) % 400 = 0)) )
Without seeing your table structure, I was just guessing how you handle friendship links
source to share