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

时间:2018-06-13 11:12:10   收藏:0   阅读:221

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 人员信息

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!