码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2018-06-13 11:37:03      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:信息   TE   SQ   diff   unit   sql查询   hda   when   from   

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】

标签:信息   TE   SQ   diff   unit   sql查询   hda   when   from   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!