Re: Question about "AT TIME ZONE"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Collin Peters" <cadiolis(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Question about "AT TIME ZONE"
Date: 2006-12-05 21:06:37
Message-ID: 11135.1165352797@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Collin Peters" <cadiolis(at)gmail(dot)com> writes:
> In the first example it says it is converted to PST "for display". In
> the second example it is not converted to PST for display. Does this
> mean that if a timestamp *with* a timezone is specified, and it also
> includes "AT TIME ZONE", that it is not converted to PST "for display"
> at the end?

AT TIME ZONE does two different things that are sort of inverses of each
other: it can convert timestamp without timezone to timestamp with
timezone, or the reverse. In the case where you're converting to ts
with tz, there's an additional step involved, which is converting the
UTC-base ts-with-tz value to your current TimeZone for display. That
happens when SELECT emits the value as text, not as part of AT TIME ZONE.

AT TIME ZONE itself basically either adds or subtracts the UTC offset of
the named time zone, thus converting a value in UTC to or from a value
that's relative to the named zone.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ted Allen 2006-12-05 21:14:07 Re: Can someone explain the problem with this select
Previous Message Richard Ray 2006-12-05 20:33:01 Can someone explain the problem with this select