MySQL中求年龄

时间函数:

1.curdate() --- 当前系统日期

调取:

select curdate()

2.curtime() --- 当前系统时间

调取:

select curtime()

3.now() --- 当前日期时间

调取:

select now()

4.year() --- 求年,注意括号内必须有内容,不得为空

求年龄可用当前系统日期的年-出生日期的年 即如下例:

select year(curdate())-year(sbirthday) as age from student // as age 是将得出的差值列为age列,即列名为age

原文地址:https://www.cnblogs.com/m-m-g-y0416/p/5538366.html