mysql - How get birthday with an interval, around New Year -
on website have overview of birthdays, 7 days 7 days forward current day.
this working query:
select * , date_format(birthday,'%m-%d') date_order employees date_add(birthday, interval year(curdate())-year(birthday) year) between date_sub(curdate(), interval 7 day) , date_add(curdate(), interval 7 day) order date_order asc
but goes wrong last days in december , first days of january. how can change query, list this:
birthdays:
- 2016/12/28: john
- 2016/12/30: (current day) ali
- 2016/12/31: mike
- 2017/01/04: mark
Comments
Post a Comment