I want to replace static (hard-coded) with dynamic timestamp with time zone value. For instance replacing '2024-06-03 00:00:00+00'
with date_trunc('day', now() - interval '1 month')
.
When the dynamic value is used, the query’s result is different when the static value is used where both (dynamic or static) values are the same.
The datatype of the timestamp column in my_table is timestamp with time zone, which is the same datatype returned by date_trunc()
.
psql=> d my_table;
Column | Type
----------+-------------------------
title | text
timestamp | timestamp with time zone
psql=> SELECT pg_typeof(date_trunc('day', now() - interval '1 month'));
pg_typeof
--------------------------
timestamp with time zone
Any idea what is wrong when using a dynamic value for the timestamp column?