mysql 计算年龄

select  
    id,  
    DATE_FORMAT(birthday,"%Y-%m-%d") birthday,  
    CURDATE() ,  
    (year(now())-year(birthday)-1) + ( DATE_FORMAT(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') ) as age  
from  
    t_user where id in (1,55000,55001);

mysql 计算年龄
 

来源 http://houzhiqingjava.blog.163.com/blog/static/167399507201362084525866/

相关推荐