Is there a way to cast a BIGINT to TIMESTAMP or TIMESTAMP WITH TIME ZONE in Postgres? I need to copy the data from a BIGINT column to the TIMESTAMP column.
Here is what I have tried:
update table
set date__timestamp = date__bigint::timestamp
where foo = 1;
ERROR: cannot cast type bigint to timestamp without time zone
I changed the timestamp column to a with timezone column and tried this:
update table
set date__timestamp = date__bigint::timestamp with time zone at time zone 'PST'
where foo = 1;
ERROR: cannot cast type bigint to timestamp with time zone
update table
set date__timstamp = TO_CHAR(TO_TIMESTAMP(date__bi / 1000), 'DD/MM/YYYY HH24:MI:SS')
where foo = 1;
ERROR: column "date__timestamp" is of type timestamp without time zone but expression is of type text Hint: You will need to rewrite or cast the expression.
The data looks like this.
date_bigint: 20181102
date_timestamp: 2018-11-02 17:00:00.000000
Do I need to pass default values to the casting?