2

I want to convert a readable timestamp to UNIX time in Amazon Athena (Presto).

For example: I want to convert 2018-08-24 18:42:16 to 1535136136000.

Here is my syntax:

    TO_UNIXTIME('2018-08-24 06:42:16') new_year_ut

My error is:

   SYNTAX_ERROR: line 1:77: Unexpected parameters (varchar(19)) for function to_unixtime. Expected: to_unixtime(timestamp) , to_unixtime(timestamp with time zone)
noobeerp
  • 123
  • 1
  • 1
  • 4

1 Answers1

3

you need to cast the string '2018-08-24 06:42:16' to one of the allowed types

TO_UNIXTIME(cast ('2018-08-24 06:42:16' as timestamp) ) new_year_ut

or

TO_UNIXTIME( timestamp '2018-08-24 06:42:16' )
Jasen
  • 3,656
  • 1
  • 15
  • 17