Need is to query the date period of the birthday of the member, divided into two situations:
1. Do not cross-year
For example: query for birthdays between 2017-01-01 and 2017-01-20 (assuming today is 2017-01-01, this can also be described as a 20-day birthday of the member)
Select * from User where Date_format (Birthday,'%m-%d'between'01-01' and ' 01-20 '
2. Cross-year
For example: query for birthdays between 2017-12-27 and 2018-01-05 members, (assuming today is 2017-12-27 this can also be described as a birthday in 10 days)
Here is the starting time of this year and the last day of this year as 1 sets of conditions, 2017-12-27 to 2017-12-31; Remove the first day of the year to the end of the next year as 1 sets of conditions: 2018-01-01 to 2018-01-05
Select * from User where(Date_format (Birthday,'%m-%d')between '12-27' and '12-31' ORDate_format (Birthday,'%m-%d')between '01-01' and '01-05')
Analysis of two kinds of query birthday situation, there is also a case of a leap year birthday, stay until next time.
We have a good plan to welcome the exchange.
MySQL querying birthdays in two ways