0

On my website I have an overview of all birthdays, from 7 days back up to 7 days forward from the current day.

This is my good working query:

SELECT * , DATE_FORMAT(birthday,'%m-%d') as date_order
FROM employees
WHERE  DATE_ADD(birthday, INTERVAL YEAR(CURDATE())-YEAR(birthday) YEAR) 
BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY)
AND DATE_ADD(CURDATE(), INTERVAL 7 DAY) ORDER BY date_order ASC

But it goes wrong the last days in december and the first days of January. How can I change this query, so I get a list like this:

Birthdays:

  • 2016/12/28: John
  • 2016/12/30: (current day) Ali
  • 2016/12/31: Mike
  • 2017/01/04: Mark
angelique000
  • 899
  • 3
  • 10
  • 28

0 Answers0