from_unixtime(unix_timestamp(cast(haofang_date as string),'yyyyMMdd'),'yyyy-MM-dd'),
concat(substr(cast(haofang_date as string),1,4), '-',substr(cast(haofang_date as string),5,2), '-',substr(cast(haofang_date as string),7,2)),
第一种
将整型的日期值转成string类型, cast(haofang_date as string)
用Hive内置的unix_timestamp函数转成时间戳类型, unix_timestamp( ??? ,‘yyyyMMdd’)
最后将时间戳用from_unixtime转成yyyy-MM-dd的日期类型。 from_unixtime( ??? ,‘yyyy-MM-dd’)
第二种
将INT类型的日期值转成STRING类型, cast(haofang_date as string)
再对字符串进行截取处理, substr( ??? ,1,4) substr( ??? ,5,2) substr( ??? ,7,2)
用-拼接起来。 concat( ??? , ‘-’, ??? , ‘-’, ??? )