X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id DE2669FA7BA for ; Mon, 11 Sep 2006 05:00:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 40009-07 for ; Mon, 11 Sep 2006 05:00:05 -0300 (ADT) X-Greylist: delayed 00:30:10.310185 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id C13719FB1C8 for ; Mon, 11 Sep 2006 05:00:02 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mail1.panix.com (mail1.panix.com [166.84.1.72]) by svr4.postgresql.org (Postfix) with ESMTP id 5DEFE5AF03D for ; Mon, 11 Sep 2006 07:29:51 +0000 (GMT) Received: from mailspool3.panix.com (mailspool3.panix.com [166.84.1.78]) by mail1.panix.com (Postfix) with ESMTP id 9876758896; Mon, 11 Sep 2006 03:29:49 -0400 (EDT) Received: from [192.168.0.1] (j074054.ppp.asahi-net.or.jp [61.213.74.54]) by mailspool3.panix.com (Postfix) with ESMTP id 06A2BD908E1; Mon, 11 Sep 2006 03:29:48 -0400 (EDT) Subject: Re: SELECT and DATE Function question From: Jason Topaz To: Mike C Cc: pgsql-admin@postgresql.org In-Reply-To: References: Content-Type: text/plain Date: Mon, 11 Sep 2006 16:29:32 +0900 Message-Id: <1157959773.2338.5.camel@trane.shiawase.org> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 (2.6.3-1.fc5.5) Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.069 tagged_above=0 required=5 tests=SPF_NEUTRAL X-Spam-Level: * X-Archive-Number: 200609/80 X-Sequence-Number: 22994 On Mon, 2006-09-11 at 16:53 +1200, Mike C wrote: > create table blah (start_date timestamp, number_of_days integer); > insert into blah values (current_timestamp, 25); > select start_date + number_of_days from blah; > > The error I get is: > > ERROR: operator does not exist: timestamp without time zone + integer > HINT: No operator matches the given name and argument type(s). You > may need to add explicit type casts. > > But according to > http://www.postgresql.org/docs/8.1/static/functions-datetime.html the > + operator should support integers and treat them as days ( date > '2001-09-28' + integer '7'). Obviously typing a constant into the > query is a lot different from using the value of a column, but I would > have thought it would work. That's because your data type was "timestamp", not "date". I don't believe the documentation claims the + operator works on a timestamp and an integer. But it does claim (correctly) that it works on a date and an integer. The following example does work: create table blah (start_date date, number_of_days integer); insert into blah values (current_date, 25); select start_date + number_of_days from blah; Hope that helps a little, at least to explain the apparent disconnect from the documentation.