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

Date Format in Impala

 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

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 | +----------------------+--+

View solution in original post

1 REPLY 1
Highlighted

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 | +----------------------+--+

View solution in original post

Don't have an account?
Coming from Hortonworks? Activate your account here