SQL数据库如何根据出生日期准确计算年龄,亲测有效 |
您所在的位置:网站首页 › 年龄应该怎样计算 › SQL数据库如何根据出生日期准确计算年龄,亲测有效 |
目标:根据出生日期计算当前的年龄 步骤: 1.创建测试用的表 create TABLE birthday_test ( id int identity(1,1) PRIMARY key , name nvarchar(50) not null, birthday datetime not null DEFAULT('2010-10-01') )2.当前日期是2020-04-24,往表中插入三条数据 INSERT into birthday_test VALUES ('张三','2010-04-23') INSERT into birthday_test VALUES ('李四','2010-04-24') INSERT into birthday_test VALUES ('王五','2010-04-25')3.查询显示数据 SELECT * FROM birthday_test
|
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |