Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 186884760CC for ; Fri, 3 May 2002 18:01:25 -0400 (EDT) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 7C35E47590F for ; Fri, 3 May 2002 17:59:02 -0400 (EDT) Received: from [209.122.114.82] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1393514; Fri, 03 May 2002 14:59:03 -0700 From: "Josh Berkus" Subject: Re: Odd behavior with timestamp/interval arithmetic To: Joseph Barillari , pgsql-sql X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Fri, 03 May 2002 14:59:03 -0700 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200205/38 X-Sequence-Number: 7674 Joe, > Adding an interval to a timestamp produces the expected result: > > cal=> select timestamp without time zone 'jan 1, 1999 00:00:00' + > interval '1 month'; > ?column? > --------------------- > 1999-02-01 00:00:00 > (1 row) > > But reversing the two produces nonsense: is this because the values > are implicitly cast to type of the leftmost term in the expression? No. It's a bug. The expression interval + timestamp was accidentally left undefined in PostgreSQL 7.2. You can fix it by using a CREATE OPERATOR statement to define Interval + timestamp. -Josh Berkus