Skip to content

Instantly share code, notes, and snippets.

@rythie
Last active December 11, 2015 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rythie/4556150 to your computer and use it in GitHub Desktop.
Save rythie/4556150 to your computer and use it in GitHub Desktop.
Birthdays in the next 7 days
WHERE DATEDIFF(
DATE(CONCAT(YEAR(DATE_ADD(NOW(), INTERVAL 7 DAY)),"-",MONTH(DATE(dob)),"-",DAY(DATE(dob)))),
DATE(NOW())
)
BETWEEN 0 AND 7
@rythie
Copy link
Author

rythie commented Jan 17, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment