日期函数小结

hive 日期函数小结

浪子不回头ぞ 提交于 2019-12-01 08:00:40
1.日期函数 to_date(string expr) 返回类型:string 描述:返回时间字符串日期部分 to_date(expr) - Extracts the date part of the date or datetime expression expr 实例: hive> select to_date('2014-09-16 15:50:08.119') from default.dual; 2014-09-16 2.年份函数 year(string expr) 返回类型:int 描述:返回时间字符串年份数字 year(date) - Returns the year of date 实例: hive> select year('2014-09-16 15:50:08.119') from default.dual; 2014 3.月份函数 month(string expr) 返回类型:int 描述:返回时间字符串月份数字 month(date) - Returns the month of date 实例: hive> select month('2014-09-16 15:50:08.119') from default.dual; 09 4.天函数 day(string expr) 返回类型:int 描述:返回时间字符串的天 day(date) -