Reputation: 137
Using Hive, I have date dates in yyyyMMdd
format and I need it in 'MM/dd/yyyy'
format.
SELECT dt,
CAST(SUBSTRING(FROM_UNIXTIME(UNIX_TIMESTAMP(dt, 'MMddyyyy')), 1, 10) AS date)
FROM timetable
Upvotes: 0
Views: 511
Reputation: 11090
No need for cast and substring.Specify the dateformat for dt in unix_timestamp()
and the desired dateformat for from_unixtime()
select
dt,
from_unixtime(unix_timestamp(dt,'yyyyMMdd'),'MM/dd/yyyy')
from timetable;
Upvotes: 1