Sort upcoming birthdays based on current date

后端 未结 5 949
庸人自扰
庸人自扰 2020-12-06 08:01

I have the following table of people and their birthdays:

name        birthday
----------------------
yannis      1979-06-29
natalia     1980-08-19
kostas            


        
5条回答
  •  误落风尘
    2020-12-06 08:26

    Seems to be rather fast, no problems with leap years:

    SELECT * 
    FROM `people` 
    ORDER BY CONCAT(SUBSTR(`birthday`,6) < SUBSTR(CURDATE(),6), SUBSTR(`birthday`,6))
    

    Все гениальное -- просто! ;)

提交回复
热议问题