Search code examples
impala

Impala Dateformat error


I have input values of

161223000001

I need to convert into

2016-12-23 00:00:01

I tried

select cast(161223000001 as timestamp)
7078-12-14 22:40:01

I am getting incorrect answers


Solution

  • You can use the to_timestamp function to convert string to timestamp in Impala

    SELECT to_timestamp('161223000001', 'yyMMddHHmmss');
    

    By using CAST AS TIMESTAMP in your original attempt, it recognizes the given string as a unix epoch time instead