0

I have one column Month_year in staging table having below data. Please suggest query to get the desired output.

Input:

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

Expected Output:

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

Thanks in Advance!

A Saraf
  • 315
  • 4
  • 20

1 Answers1

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')
Shambhu Nath
  • 109
  • 4