SQL已知出生日期如何计算年龄?
现有如下学生信息表:<问题>根据学生的出生日期, 查询各学生的年龄,按照年份来算<思路>在SQL中,一般可以使用year函数来计算已知出生日期求年龄的问题<解>SELECT sid,sname, ssex,sage, year(getdate())-year(sage) as agefrom student;SELECT sid,sname, ssex,sage
·
现有如下学生信息表:
<问题>根据学生的出生日期, 查询各学生的年龄,按照年份来算
<思路>在SQL中,一般可以使用year函数来计算已知出生日期求年龄的问题
<解>
SELECT sid,sname, ssex,sage, year(getdate())-year(sage) as age
from student;
SELECT sid,sname, ssex,sage, year(getdate())-year(sage) as age
from student;
查询结果如下:
更多推荐
已为社区贡献1条内容
所有评论(0)