sql 根据身份证号码计算年龄

select PersonalId ,FLOOR(DATEDIFF(DY, substring(PersonalId,7,4), GETDATE()) / 365.25) from ConstructionInfo 
原文地址:https://www.cnblogs.com/xiaonangua/p/10735855.html