Get Birthdays for the month (Mysql)

Language::mysql MySQL Type:: Back-end Context:: database query

Description – Get the birthdays for the month from a users table

Snippet – the actual snippet/boilerplate (wrapped in code tags)

SELECT `user`.firstName, user.lastName, birthday 
FROM `user`
WHERE (DAYOFYEAR('2012-05-15') <= DAYOFYEAR(DATE_ADD(`birthday`, INTERVAL(YEAR(NOW())-YEAR(`birthday`)) YEAR)))
AND (DAYOFYEAR('2012-05-31') >= DAYOFYEAR(DATE_ADD(`birthday`, INTERVAL(YEAR(NOW())-YEAR(`birthday`)) YEAR)))
AND (groupId >= 3)
ORDER BY substring(birthday, 6, 10) ASC;

Dependencies:: MySQL

Type::snippet