I am trying to convert the bigint value to date in PostgreSQL
I am using the below code
SELECT TO_CHAR(TO_TIMESTAMP(1564983632051/ 1000),
'YYYY-MM-DD HH24:MI:SS')
then its returning 2019-08-05 07:40:32
, which is correct.
However i want to add few hours to it to get local time. Tried with the following query but its throwing an error :
SELECT TO_CHAR(TO_CHAR(TO_TIMESTAMP(1564983632051/ 1000),
'YYYY-MM-DD HH24:MI:SS') + INTERVAL '4 hour')
I do not want to use a separate query, if that's the case i can use select (to_timestamp('2019-08-05 07:40:32', 'YYYY-MM-DD HH24:MI:SS.US') + interval '4 hour')::timestamp; this will return the desired output.
I need both conversion and hours addition in a single query.
timestamp
column. – a_horse_with_no_name