Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFle3-0004II-EW for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Feb 2014 14:27:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WFle2-0001yL-UO for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Feb 2014 14:27:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFle2-0001yF-BQ for pgsql-bugs@postgresql.org; Tue, 18 Feb 2014 14:27:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFldv-0002IZ-MQ for pgsql-bugs@postgresql.org; Tue, 18 Feb 2014 14:27:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s1IEQHTJ023718; Tue, 18 Feb 2014 09:26:17 -0500 From: Tom Lane To: miaoyimin@huawei.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #9265: why the same interval can't get the same timestamp? In-reply-to: <20140218120621.24620.15178@wrigleys.postgresql.org> References: <20140218120621.24620.15178@wrigleys.postgresql.org> Comments: In-reply-to miaoyimin@huawei.com message dated "Tue, 18 Feb 2014 12:06:21 +0000" Date: Tue, 18 Feb 2014 09:26:17 -0500 Message-ID: <23717.1392733577@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) 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 miaoyimin@huawei.com writes: > postgres=# select ('epoch'::pg_catalog.timestamptz + 1386201600 * '1 > second'::pg_catalog.interval); > ?column? > ------------------------ > 2013-12-05 08:00:00+08 > (1 row) > postgres=# select ('epoch'::pg_catalog.timestamptz + 16044 * '1 > day'::pg_catalog.interval); > ?column? > ------------------------ > 2013-12-05 07:30:00+08 > (1 row) It's intentional that those don't give the same result. Adding days is DST-aware, adding seconds is not. Since the epoch in that zone was # select 'epoch'::pg_catalog.timestamptz; timestamptz --------------------------- 1970-01-01 07:30:00+07:30 (1 row) adding any number of days to it will produce 07:30 local time on the selected day, even though the zone offset changes. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs