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)
1
  • FYI: Presto SQL is now Trino Commented Jan 29, 2021 at 21:21

1 Answer 1

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' )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.