时间转换的时候hive对日期的大小写是敏感的:
年-月-日:yyyy-MM-dd;
但是trunc截取的时候,年份,月份都需要大写
SELECT current_date() date1
,trunc(current_date(),'YYYY') date2
,trunc(current_date(),'yyyy') date3
,trunc(current_date(),'mm') date3_1
,trunc(current_date(),'MM') date3_2
,from_unixtime(unix_timestamp(current_timestamp(),'yyyyMMdd'),'yyyy-MM-dd') date4
,from_unixtime(unix_timestamp(current_timestamp(),'yyyymmdd'),'yyyy-mm-dd') date5
,from_unixtime(unix_timestamp(current_timestamp(),'YYYYMMdd'),'YYYY-MM-dd') date6
,from_unixtime(unix_timestamp(current_timestamp(),'YYYYmmdd'),'YYYY-mm-dd') date7
,date_format(current_timestamp(),'yyyyMMdd') date8
,date_format(current_timestamp(),'yyyymmdd') date9