您的位置:首页 > 数据库

SQL:将表中生日字段转化为年龄

2016-09-29 11:12 190 查看
假设表中生日字段为 user_birthday

在不计 日时分秒 的情况下:

生日                  ==>  年龄
user_birthday ==>  floor(((year(current_date)-year(user_birthday))*12+month(current_date)-month(user_birthday))/12)

计算 日时分秒 的情况下:

……

Hive UDF 官网:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions 生日                  ==>  年龄
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sql date 生日 年龄 HQL