Support Questions
Find answers, ask questions, and share your expertise

Date Format in Impala

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

View solution in original post

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

View solution in original post