Re: Question about "AT TIME ZONE" - Mailing list pgsql-sql

From Tom Lane
Subject Re: Question about "AT TIME ZONE"
Date
Msg-id 11135.1165352797@sss.pgh.pa.us
Whole thread Raw
In response to Question about "AT TIME ZONE"  ("Collin Peters" <cadiolis@gmail.com>)
List pgsql-sql
"Collin Peters" <cadiolis@gmail.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


pgsql-sql by date:

Previous
From: Din Adrian
Date:
Subject: Re: transaction in function
Next
From: Tom Lane
Date:
Subject: Re: Can someone explain the problem with this select