Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1api3n-0007sn-K1 for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Apr 2016 20:03:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1api3m-000313-Q5 for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Apr 2016 20:03:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1apNWb-00063Z-Ur for pgsql-bugs@postgresql.org; Sun, 10 Apr 2016 22:08:09 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1apNWW-0002nG-Id for pgsql-bugs@postgresql.org; Sun, 10 Apr 2016 22:08:09 +0000 MIME-Version: 1.0 Subject: BUG #14082: Unexpected time adjustment for output using "at time zone" To: pgsql-bugs@postgresql.org From: duncan.stokes@eyemagnet.com Date: Sun, 10 Apr 2016 22:07:38 +0000 Message-ID: <20160410220738.15199.93161@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.2 (-) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 14082 Logged by: Duncan Stokes Email address: duncan.stokes@eyemagnet.com PostgreSQL version: 9.2.15 Operating system: CentOS Linux release 7.2.1511 (Core) Description: Getting an unexpected output when using the "at time zone" function with numerical (e.g. +12 or -12) time zones. For the following table: datetimetest=# CREATE TABLE datetimetest_log (id serial PRIMARY KEY UNIQUE NOT NULL, datetime timestamptz(0) NOT NULL DEFAULT NOW(), comment text NOT NULL); For the following data: datetimetest=# SELECT * FROM datetimetest_log; id | datetime | comment ----+------------------------+--------- 1 | 2016-04-11 09:51:35+12 | Test #1 2 | 2016-04-11 09:51:37+12 | Test #2 (2 rows) Get the following responses: datetimetest=# SELECT datetime AT TIME ZONE INTERVAL '+12:00' FROM datetimetest_log; timezone --------------------- 2016-04-11 09:51:35 2016-04-11 09:51:37 (2 rows) datetimetest=# SELECT datetime AT TIME ZONE '+12' FROM datetimetest_log; timezone --------------------- 2016-04-10 09:51:35 ** WRONG DATE FOR +12 ZONE ** 2016-04-10 09:51:37 ** WRONG DATE FOR +12 ZONE ** (2 rows) datetimetest=# SELECT datetime AT TIME ZONE INTERVAL '-12:00' FROM datetimetest_log; timezone --------------------- 2016-04-10 09:51:35 2016-04-10 09:51:37 (2 rows) datetimetest=# SELECT datetime AT TIME ZONE '-12' FROM datetimetest_log; timezone --------------------- 2016-04-11 09:51:35 ** WRONG DATE FOR -12 ZONE ** 2016-04-11 09:51:37 ** WRONG DATE FOR -12 ZONE ** (2 rows) datetimetest=# SELECT datetime AT TIME ZONE 'NZT' FROM datetimetest_log; timezone --------------------- 2016-04-11 09:51:35 2016-04-11 09:51:37 (2 rows) Having read the documentation (section 8.5.3), I can't actually see any allowance for this formatted timezone (e.g. +12 or -12). So, either the functionality needs correcting and the documentation updated to reflect that this is a valid timezone format or the functionality needs to be amended to reject (i.e. error) this timezone format. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs