Impala-将MON-YY转换为YYYYMM

时间:2019-01-12 15:48:11

标签: hive hiveql impala

我的登台表中有Month_year列,其中包含以下数据。请建议查询以获取所需的输出。

输入:

+----------+
month_year
+----------+
Jan-19
Dec-18
+----------+

预期输出:

+----------+
month_year
+----------+
201901
201812
+----------+

预先感谢!

1 个答案:

答案 0 :(得分:0)

If column's month_year date format is MMM-yy then contact 01 as default date for avoid to null result, however it will not effect expected out because you are going to get output in format yyyyMM.  
Try this:  
select from_unixtime(unix_timestamp(concat('01-',month_year),'dd-MMM-yy'),'yyyyMM')