Last active
December 11, 2015 05:58
-
-
Save rythie/4556150 to your computer and use it in GitHub Desktop.
Birthdays in the next 7 days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WHERE DATEDIFF( | |
DATE(CONCAT(YEAR(DATE_ADD(NOW(), INTERVAL 7 DAY)),"-",MONTH(DATE(dob)),"-",DAY(DATE(dob)))), | |
DATE(NOW()) | |
) | |
BETWEEN 0 AND 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also I checked it still works where now() is 2012-12-31 and their bithday is 1980-01-01...
SELECT DATEDIFF(DATE(CONCAT(YEAR(DATE_ADD('2012-12-31', INTERVAL 7 DAY)),"-",MONTH(DATE('1980-01-01')),"-",DAY(DATE('1980-01-01')))), DATE('2012-12-31'));
still breaks if their birthday is on the 29th Feb and there isn't one this year though