From docs https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-INPUT-TIME-STAMPS
TIMESTAMP ‘2004-10-19 10:23:54+02’
is a timestamp with time zone
Question: Why select pg_typeof(TIMESTAMP '2004-10-19 10:23:54+02');
gives timestamp without time zone
? Expecting timestamp with time zone
as docs say.
Postgres version
SELECT version();
shows
PostgreSQL 14.14 (Debian 14.14-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2
Answers
As it says in that very documentation you link to:
timestamp
meanstimestamp
withOUT
time zone
. That’s the type you used explicitly and that’s whatpg_typeof()
just repeated after after you.timestampTZ
meanstimestamp
with
time zone
. That’s what you want and that’s the realpg_types.typname
.demo at db<>fiddle
Postgres can always clarify things like that if you ask it to
explain verbose
: