Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 9CA521337B5C for ; Thu, 17 Feb 2011 03:51:55 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 28531-09 for ; Thu, 17 Feb 2011 07:51:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og111.obsmtp.com (exprod7og111.obsmtp.com [64.18.2.175]) by mail.postgresql.org (Postfix) with ESMTP id 854FB1337B34 for ; Thu, 17 Feb 2011 03:51:46 -0400 (AST) Received: from source ([209.85.215.53]) (using TLSv1) by exprod7ob111.postini.com ([64.18.6.12]) with SMTP ID DSNKTVzTkYUMaudIcLy9KtyYPqA/FMaAGIkm@postini.com; Wed, 16 Feb 2011 23:51:47 PST Received: by mail-ew0-f53.google.com with SMTP id 6so812784ewy.12 for ; Wed, 16 Feb 2011 23:51:45 -0800 (PST) Received: by 10.213.9.14 with SMTP id j14mr1801181ebj.29.1297928554032; Wed, 16 Feb 2011 23:42:34 -0800 (PST) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id x54sm602159eeh.5.2011.02.16.23.42.32 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 Feb 2011 23:42:33 -0800 (PST) Message-ID: <4D5CD167.10908@enterprisedb.com> Date: Thu, 17 Feb 2011 09:42:31 +0200 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.16) Gecko/20101226 Icedove/3.0.11 MIME-Version: 1.0 To: Sachin Srivastava CC: pgsql-bugs@postgresql.org Subject: Re: timestamp issue References: <379DB7E6-D1DD-4ADB-9454-5D67E9BF416D@enterprisedb.com> In-Reply-To: <379DB7E6-D1DD-4ADB-9454-5D67E9BF416D@enterprisedb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.2 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201102/153 X-Sequence-Number: 29425 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