Re: timestamp issue

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Sachin Srivastava <sachin(dot)srivastava(at)enterprisedb(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: timestamp issue
Date: 2011-02-17 07:42:31
Message-ID: 4D5CD167.10908@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 17.02.2011 08:06, Sachin Srivastava wrote:
> postgres=# SELECT now() + '7 days' AS week_ahead;
> week_ahead
> ----------------------------------
> 2011-02-24 10:39:29.951931+05:30
> (1 row)
>
> postgres=# SELECT now() - '7 days' AS week_behind;
> ERROR: invalid input syntax for type timestamp with time zone: "7 days"
> LINE 1: SELECT now() - '7 days' AS week_behind;
> ^
>
> Now, if '+' operator works with '7 days', why dint the '-' operator? Is this intentional or a bug?

Intentional, or at least coincidental.

postgres=# SELECT oprname, oprleft::regtype, oprright::regtype FROM
pg_operator WHERE oprleft ='timestamptz'::regtype AND oprname IN('+', '-');
oprname | oprleft | oprright
---------+--------------------------+--------------------------
+ | timestamp with time zone | interval
- | timestamp with time zone | timestamp with time zone
- | timestamp with time zone | interval
(3 rows)

With '-', it's getting interpreted as timestamptz-timestamptz.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Vegard Bønes 2011-02-17 07:58:05 Re: BUG #5883: Error when mixing SPI_returntuple with returning regular HeapTuple
Previous Message Sachin Srivastava 2011-02-17 06:06:09 timestamp issue