mysql计算年龄

YEAR(CURDATE())-YEAR(addtime)-(RIGHT(CURDATE(),5)<RIGHT(addtime,5))

addtime='2006-11-2'
mysql> SELECT id,  YEAR(CURDATE())-YEAR(addtime)-(RIGHT(CURDATE(),5)<RIGHT(addtime,5))   FROM user  where id='109480'

来自:http://www.cnblogs.com/fenglie/p/3985521.html

 

posted @ 2016-10-16 10:37  Xiao|Deng  阅读(1828)  评论(0编辑  收藏  举报