码迷,mamicode.com
首页 > 数据库 > 详细

MySQL中求年龄

时间:2016-05-28 21:51:50      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:

时间函数:

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

MySQL中求年龄

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!