When I call max
on two timestamps, I get an error :
select max(now()::timestamp, to_timestamp('2021-01-01', 'YYYY-MM-DD')::timestamp);
-- ERROR: function max(timestamp without time zone, timestamp without time zone) does not exist
My actual usage would be in an upsert query, where I would like to write :
INSERT ...
ON CONFLICT (pk) DO UPDATE SET
ts = max(table.ts, excluded.ts)
Question
Is there an idiomatic way to take the max between two timestamps in PostgreSQL ?