mysql中查询生日提醒的日期相关的sql

SELECT sysid,user_name,birthday,listid,userhead_50,CONCAT(YEAR(CURDATE()),DATE_FORMAT(birthday,'-%m-%d')),CURDATE(),  dayofyear( CONCAT(YEAR(CURDATE()),DATE_FORMAT(birthday,'-%m-%d')))-dayofyear(CURDATE()) FROM dream_list_user WHERE  CONCAT(YEAR(CURDATE()),DATE_FORMAT(birthday,'-%m-%d'))  BETWEEN CURDATE() AND ADDDATE(CURDATE(),INTERVAL "+n+" DAY) AND YEAR(birthday) >= 1900 AND YEAR(birthday) <= YEAR(CURDATE()) and listid="+listid+" order by birthday asc

 

 

 

CONCAT(YEAR(CURDATE()),DATE_FORMAT(birthday,'-%m-%d'))  代表把生日调整为今年的生日日期

 CONCAT(YEAR(CURDATE()),DATE_FORMAT(birthday,'-%m-%d'))  BETWEEN CURDATE() AND ADDDATE(CURDATE(),INTERVAL "+n+" DAY)  代表查找n天以内的生日日期

 

你可能感兴趣的:(mysql)