From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Sachin Srivastava <sachin.srivastava@enterprisedb.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: timestamp issue
Date: Thu, 17 Feb 2011 09:42:31 +0200
Message-ID: <4D5CD167.10908@enterprisedb.com> (raw)
In-Reply-To: <379DB7E6-D1DD-4ADB-9454-5D67E9BF416D@enterprisedb.com>
References: <379DB7E6-D1DD-4ADB-9454-5D67E9BF416D@enterprisedb.com>
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: heikki.linnakangas@enterprisedb.com, sachin.srivastava@enterprisedb.com
Subject: Re: timestamp issue
In-Reply-To: <4D5CD167.10908@enterprisedb.com>
References: <379DB7E6-D1DD-4ADB-9454-5D67E9BF416D@enterprisedb.com> <4D5CD167.10908@enterprisedb.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