1
votes

Currently, I have a column in a Hive table as YYYY-MM. The data format is string. Instead of string, I want to make it data type as date but still keep it as YYYY-MM. Is that possible? When I make it date data type, it's getting changed to YYYY-MM-DD.

1

1 Answers

1
votes

You can utilize below function for date conversions.

select from_unixtime(unix_timestamp('20100803' ,'yyyyMMdd'), 'yyyy-MM-dd') 

Also, You can have it converted to several formats like you wish to as below. enter image description here