Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fwJ3w-0007f6-C3 for pgsql-docs@arkaria.postgresql.org; Sun, 02 Sep 2018 03:28:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fwJ3t-0007Ts-TK for pgsql-docs@arkaria.postgresql.org; Sun, 02 Sep 2018 03:28:29 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fwJ3t-0007Tl-KH for pgsql-docs@lists.postgresql.org; Sun, 02 Sep 2018 03:28:29 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fwJ3m-0001lW-JC for pgsql-docs@postgresql.org; Sun, 02 Sep 2018 03:28:28 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1fwJ3l-0000Pj-1t; Sat, 01 Sep 2018 23:28:21 -0400 Date: Sat, 1 Sep 2018 23:28:21 -0400 From: Bruce Momjian To: Tom Lane Cc: PostgreSQL-documentation Subject: Re: AT TIME ZONE correction Message-ID: <20180902032821.GB25700@momjian.us> References: <20180901225557.GA22406@momjian.us> <24277.1535844643@sss.pgh.pa.us> <20180901233736.GA25700@momjian.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="u3/rZRmxL6MmkK24" Content-Disposition: inline In-Reply-To: <20180901233736.GA25700@momjian.us> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --u3/rZRmxL6MmkK24 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Sep 1, 2018 at 07:37:36PM -0400, Bruce Momjian wrote: > > Here we've got a time value that was initially given in EST (-05), > > but was converted to UTC by timestampz_in. Then the AT TIME ZONE > > says "Please convert this UTC value to MST, and emit it as a zoneless > > timestamp" (which will not be subject to any further conversion when > > it's displayed). > > > > The existing text is indeed a bit deficient, because it fails to > > draw a clear boundary between what the AT TIME ZONE operator is > > doing and what is being done by the timestamp(tz) I/O functions. > > But you're not making it better. > > Yes, I am still researching and realize my diff is wrong. Let me keep > working and I will repost. I have developed the attached patch, which I think is an improvement. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription + --u3/rZRmxL6MmkK24 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="time_zone.diff" diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml new file mode 100644 index bb794e0..53aa515 *** a/doc/src/sgml/func.sgml --- b/doc/src/sgml/func.sgml *************** SELECT date_trunc('year', TIMESTAMP '200 *** 8082,8089 **** ! The AT TIME ZONE construct allows conversions ! of time stamps to different time zones. shows its variants. --- 8082,8089 ---- ! The AT TIME ZONE construct allows the addition, ! conversion, and removal of time zones for time stamp values. shows its variants. *************** SELECT TIMESTAMP '2001-02-16 20:38:40' A *** 8145,8153 **** SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST'; Result: 2001-02-16 18:38:40 ! The first example takes a time stamp without time zone and interprets it as MST time ! (UTC-7), which is then converted to PST (UTC-8) for display. The second example takes ! a time stamp specified in EST (UTC-5) and converts it to local time in MST (UTC-7). --- 8145,8159 ---- SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST'; Result: 2001-02-16 18:38:40 ! The first example takes a time stamp without time zone and interprets ! it in the MST time zone (UTC-7), returning a time stamp with time ! zone value which is displayed in local time (PST, UTC-8). The second ! example takes a time stamp with time zone value (EST, UTC-5) and ! converts it to the date and time in MST (UTC-7) without time zone. ! Basically, the first example takes the date and time and puts it in ! the specified time zone. The second example takes a time stamp with ! time zone and shifts it to the specified time zone. (No time zone ! designation is returned.) --u3/rZRmxL6MmkK24--