Hi.
I just had some fun trying to build a MySQL query that will return birthdays for the 7 coming days including today... I cared about New Year... I'd just like to know what you think of it...
SELECT
p84ue.user_id,
p84ue.Anniversaire,
IF(month(anniversaire) = 1 AND month(NOW()) = 12, INSERT(SUBSTRING(Anniversaire, 6, 5), 1, 2, 13), SUBSTRING(Anniversaire, 6, 5)) as Jour_Mois
FROM
p84_users_extras p84ue
WHERE
IF(month(anniversaire) = 1 AND month(NOW()) = 12, INSERT(SUBSTRING(Anniversaire, 6, 5), 1, 2, 13), SUBSTRING(Anniversaire, 6, 5)) >= SUBSTRING(NOW(), 6, 5)
AND
IF(month(anniversaire) = 1 AND month(NOW()) = 12, INSERT(SUBSTRING(Anniversaire, 6, 5), 1, 2, 13), SUBSTRING(Anniversaire, 6, 5)) < INSERT(SUBSTRING(DATE_ADD(NOW(),INTERVAL 7 DAY), 6, 5), 1, 2, IF(month(DATE_ADD(NOW(),INTERVAL 7 DAY)) < month(NOW()), '13', '12'))
ORDER BY
Jour_Mois ASC
To make it short, it looks at the month and day (mm-dd). That has to be higher or equal to the current month and day, and must be inferior to today + seven days. But if the current month is 12 and the month of a row in the table is 01, it is changed to 13, that's why the query is so long...