5
votes

I have a column which has dates in the format mm/dd/yyyy. How do I convert it into yyyy-mm-dd format?

Tried this:- hive> select to_date(from_unixtime(unix_timestamp('02/22/2015', 'yyyy-mm-dd'))); but it doesn't work

2

2 Answers

9
votes

You can try this:

select from_unixtime(unix_timestamp('02/22/2015' ,'MM/dd/yyyy'), 'yyyy-MM-dd') from table;
0
votes

This should work:

to_date(from_unixtime(unix_timestamp(regexp_replace("value", '/' , '-'), 'yyyy-MM-dd'))) as value