0

How do I convert a DoubleType into a Timestamp in Impala ?

I have the following doubletype format:

month_date: 201710

I would have thought something like:

SELECT  
to_timestamp(cast (t1.month_date as string),  'yyyy-MM')
FROM old t1;

I am getting all Null

in

Anna
  • 444
  • 1
  • 5
  • 23
  • if I do : SELECT (cast (t1.month_date as TIMESTAMP)) then I get for 201207 == 1970-01-03 19:53:27 How do I have to convert double_type? – Anna Nov 30 '18 at 07:49
  • how do I implement this ? : You can use CAST() to convert DOUBLE values to TIMESTAMP. Casting an integer or floating-point value N to TIMESTAMP produces a value that is N seconds past the start of the epoch date (January 1, 1970). By default, the result value represents a date and time in the UTC time zone. If the setting --use_local_tz_for_unix_timestamp_conversions=true is in effect, the resulting TIMESTAMP represents a date and time in the local time zone. https://www.cloudera.com/documentation/enterprise/5-9-x/topics/impala_double.html – Anna Nov 30 '18 at 09:08

0 Answers0