"Stefan Murphy" <stefan@vocalocity.com> writes:
I'm seeing some odd behavior (to me) around a timestamp without timezone
column. Was hoping someone could shed some light on this for me. I
insert current_timestamp into the column. When I select the value it is
the expected UTC time. When I select the value with "AT TIME ZONE EDT"
I expected it to return in eastern time which is UTC - 4, but is
returning as UTC + 4. Is AT TIME ZONE incompatable with this data type?
It's operating as intended, which is not compatible with your
expectation. AT TIME ZONE on a timestamp WITHOUT tz means "assume that
the given timestamp is local time in this timezone. Rotate it to UTC
and return that as a timestamp WITH tz". For display, the result gets
rotated to your display timezone (TimeZone setting), which evidently is
UTC. So 16:58 in EDT is in fact 20:58 in UTC.

I think the behavior you're after is probably the one associated with
the reverse transform, ie start from a timestamp WITH tz and get one
without.

In general, if you're trying to store a column that represents actual
instants in time, the column type should be timestamp with tz. When you
use timestamp without tz the interpretation changes depending on the
timezone setting, which is almost surely not what you want.

regards, tom lane

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 3 | next ›
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedOct 17, '08 at 5:44p
activeOct 17, '08 at 6:37p
posts3
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Stefan Murphy: 2 posts Tom Lane: 1 post

People

Translate

site design / logo © 2022 Grokbase