timestamp arithmetic

Started by Ed L.over 21 years ago2 messagesbugs
Jump to latest
#1Ed L.
pgsql@bluepolka.net

Note the queries below generate the same result regardless of the timezone input:

% env | grep TZ
PGTZ=CST6CDT
TZ=CST6CDT

% psql -t -c "select version()"
PostgreSQL 8.0.0beta3 on i686-pc-linux-gnu, compiled by GCC 2.96

% psql -t -c "select '1970-01-01 00:00:00+09'::timestamp + '1089352800 seconds'::interval"
2004-07-09 06:00:00

% psql -t -c "select '1970-01-01 00:00:00+03'::timestamp + '1089352800 seconds'::interval"
2004-07-09 06:00:00

% psql -t -c "select '1970-01-01 00:00:00+01'::timestamp + '1089352800 seconds'::interval"
2004-07-09 06:00:00

Ed

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ed L. (#1)
Re: timestamp arithmetic

"Ed L." <pgsql@bluepolka.net> writes:

Note the queries below generate the same result regardless of the timezone input:

This isn't a bug. Per documentation:

: For timestamp [without time zone], any explicit time zone specified in
: the input is silently ignored. That is, the resulting date/time value is
: derived from the explicit date/time fields in the input value, and is
: not adjusted for time zone.

You want to use timestamp with time zone (timestamptz), I think.

regards, tom lane