mysql计算年龄
2019-01-24 本文已影响0人
zhihaoZzz
- 取生日和当前日期之前的天数除以一年的实际天数(365天5小时48分46秒),然后取整
floor(DATEDIFF(CURDATE(),@birthday)/365.2422)
SELECT TIMESTAMPDIFF(YEAR,@birthday,CURDATE())
floor(DATEDIFF(CURDATE(),@birthday)/365.2422)
SELECT TIMESTAMPDIFF(YEAR,@birthday,CURDATE())