Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Date Format in Impala

avatar
Rising Star
 
1 ACCEPTED SOLUTION

avatar
Master 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

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