Thread: timestamp arithmetic

timestamp arithmetic

From
"Ed L."
Date:
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

Re: timestamp arithmetic

From
Tom Lane
Date:
"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