Re: timestamptz insert - Mailing list pgsql-novice

From Tom Lane
Subject Re: timestamptz insert
Date
Msg-id 18974.1074553203@sss.pgh.pa.us
Whole thread Raw
In response to timestamptz insert  ("Seader, Cameron" <CSeader@idahopower.com>)
List pgsql-novice
"Seader, Cameron" <CSeader@idahopower.com> writes:
> When i insert data into the timestamptz field it is  automatically adding on
> the time zone of MST which is not correct. The data that is being inserted
> is not MST it is GMT. how do i make it insert as GMT.

You can either SET TIMEZONE TO 'GMT' or explicitly specify -00 in the
input data.  If you want it to come back out in GMT then you will
definitely need to set the timezone value.

Realize that what is stored in the database is GMT in any case.  If you
enter a timestamp that doesn't mention any particular zone, then it is
assumed to be in the zone specified by the timezone variable.  In either
case, a non-GMT timestamp is then adjusted to GMT for storage.  When the
value is displayed, it is adjusted back to the zone currently selected
by the timezone variable (which might or might not be the same as the
zone it was originally entered in).  A little experimentation with
changing timezone and seeing how entry and output are affected should
make this clearer.

            regards, tom lane

pgsql-novice by date:

Previous
From: "Seader, Cameron"
Date:
Subject: timestamptz insert
Next
From: Noel
Date:
Subject: long deletes :( Pls help