Search code examples
sqlimpala

Impala: set a constant date for timestamp


is there an alternative to the to_char() function in impala? I want to set a timestamp field where the date and minutes are fixed and only showing the hours, but can't seem to find an alternative.

This is my existing code in postgres which I need to convert to impala.

select to_char(starttime, '1900-01-01 HH24:00:00')::timestamp

Any help is appreciated!


Solution

  • In Impala, you can use

    SELECT hours_add('1900-01-01', hour(now()));
    

    to get the same result

    • function hour extracts the hour part from a timestamp
    • function hours_add adds hour to a timestamp