首页 > 数据库技术 > 详细

SQL查询【根据生日计算ji】

时间:2018-06-13 11:12:10      阅读:218      评论:0      收藏:0      [点我收藏+]

select Case when DateDiff(Year, BirthDate, GetDate()) > 0 then DateDiff(Year, BirthDate, GetDate())
                    when DateDiff(Month, BirthDate, GetDate()) > 0 then DateDiff(MONTH, BirthDate, GetDate())
                    When DATEDIFF(DAY, BirthDate, GetDate()) > 0 then DateDiff(DAY, BirthDate, GetDate()) end Age,
           Case When DateDiff(Year, BirthDate, GetDate()) > 0 then ‘岁‘
                    When DateDiff(Month, BirthDate, GetDate()) > 0 then ‘月‘
                    When DATEDIFF(DAY, BirthDate, GetDate()) > 0 then ‘日‘ end AgeUnit, BirthDate BirthDate
From 人员信息

SQL查询【根据生日计算ji】

原文:https://www.cnblogs.com/meitai/p/9175782.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!