pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <agliodbs@openoffice.org>
To: Joseph Barillari <jbarilla@princeton.edu>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Odd behavior with timestamp/interval arithmetic
Date: Fri, 03 May 2002 14:59:03 -0700
Message-ID: <web-1393514@davinci.ethosmedia.com> (raw)
In-Reply-To: <m3wuulj7bd.fsf@washer.barillari.org>

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



view thread (2+ messages)

Message-ID: <web-1393514@davinci.ethosmedia.com>
Permalink:  ../web-1393514@davinci.ethosmedia.com/
Also on:    postgresql.org/message-id/web-1393514@davinci.ethosmedia.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: agliodbs@openoffice.org, jbarilla@princeton.edu
  Subject: Re: Odd behavior with timestamp/interval arithmetic
  In-Reply-To: <web-1393514@davinci.ethosmedia.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox