Re: Odd behavior with timestamp/interval arithmetic - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Odd behavior with timestamp/interval arithmetic
Date
Msg-id web-1393514@davinci.ethosmedia.com
Whole thread Raw
In response to Odd behavior with timestamp/interval arithmetic  (Joseph Barillari <jbarilla@princeton.edu>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Gary Stainburn
Date:
Subject: summary VIEW
Next
From: Gary Stainburn
Date:
Subject: Re: summary VIEW