Q:

how to convert a timestamp to int in sql (vertica)

I have a timestamp as 2017-07-19 11:45:01and i want it to convert to int.
Query:
select cast(max(event_timestamp) as INT) from error_messages where error_level='ERROR' and user_name='git'

Error:
SQL Error [2366] [42846]: [Vertica][VJDBC](2366) ERROR: Cannot cast type timestamptz to int
  [Vertica][VJDBC](2366) ERROR: Cannot cast type timestamptz to int
    com.vertica.util.ServerException: [Vertica][VJDBC](2366) ERROR: Cannot cast type timestamptz to int

A:

You have to use TIMESTAMPDIFF() this way:
SELECT TIMESTAMPDIFF(SECOND,'001-01-01 00:00:00', '2015-02-23 03:12:35');
 timestampdiff 
---------------
   63560257955

to get the number of time units you want (SECONDs here above) since the timestamp you want...

