Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Date Format in Impala

Solved Go to solution
Highlighted

Date Format in Impala

New Contributor
 
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Date Format in Impala

Super Guru
@Gayathri Devi

Instead of cast you need to use from_unixtime

Try the below query will result correct outputs as you are expecting

hive# select from_unixtime(unix_timestamp('161223000001' ,'yyMMddhhmmss'), 'yyyy-MM-dd HH:mm:ss');
+----------------------+--+
|         _c0          |
+----------------------+--+
| 2016-12-23 00:00:01  |
+----------------------+--+

hive# select from_unixtime(unix_timestamp('161223000001' ,'yyMMddhhmmss'), 'yyyy-MM-dd hh:mm:ss'); +----------------------+--+ | _c0 | +----------------------+--+ | 2016-12-23 12:00:01 | +----------------------+--+
1 REPLY 1

Re: Date Format in Impala

Super Guru
@Gayathri Devi

Instead of cast you need to use from_unixtime

Try the below query will result correct outputs as you are expecting

hive# select from_unixtime(unix_timestamp('161223000001' ,'yyMMddhhmmss'), 'yyyy-MM-dd HH:mm:ss');
+----------------------+--+
|         _c0          |
+----------------------+--+
| 2016-12-23 00:00:01  |
+----------------------+--+

hive# select from_unixtime(unix_timestamp('161223000001' ,'yyMMddhhmmss'), 'yyyy-MM-dd hh:mm:ss'); +----------------------+--+ | _c0 | +----------------------+--+ | 2016-12-23 12:00:01 | +----------------------+--+
Don't have an account?
Coming from Hortonworks? Activate your account here