mysql根据出生年月日计算年龄大小
SELECT age,DATE_FORMAT(NOW(),'%Y/%m/%d'),(YEAR(NOW())-YEAR(age)-1) + ( DATE_FORMAT(age, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') ) AS 年龄 FROM users AS u另外大家可以研究下下面三种计算函数SELECTTIMESTAMPDIFF(Y...
·
SELECT age,DATE_FORMAT(NOW(),'%Y/%m/%d'),(YEAR(NOW())-YEAR(age)-1) + ( DATE_FORMAT(age, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') ) AS 年龄 FROM users AS u
另外大家可以研究下下面三种计算函数
SELECT TIMESTAMPDIFF(YEAR, '2000-12-27', CURDATE());
SELECT FLOOR(DATEDIFF(CURDATE(), '2000-12-27')/365.2422);
SELECT ROUND(DATEDIFF(CURDATE(),'2000-12-27')/365.2422);
- 感谢您的阅读。如果感觉文章对您有用,麻烦您动动手指点个赞,以资鼓励。谢谢!
更多推荐
已为社区贡献3条内容
所有评论(0)