X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 01A1A9FA3B1 for ; Mon, 11 Sep 2006 01:53:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 24731-07 for ; Mon, 11 Sep 2006 04:53:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.176]) by postgresql.org (Postfix) with ESMTP id AA8B09F9F80 for ; Mon, 11 Sep 2006 01:53:37 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id d80so1993882pyd for ; Sun, 10 Sep 2006 21:53:36 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=mvqiwYuP+01T6fiP7NxGejdAEGntUVTKV224qMdrFesDWLx+EBxWaquAvY8+tn0vSRbqVmnJoXrYQEMWDALmm5k9q0RKe1KKmhrg9CpVzcW+wCaNdX/X2hctKbpWEGQjFnVykq5jrFdVKoYcbYJ5TsypCgUd7F4t/FEgFpgFHLs= Received: by 10.65.153.10 with SMTP id f10mr1362574qbo; Sun, 10 Sep 2006 21:53:36 -0700 (PDT) Received: by 10.65.54.11 with HTTP; Sun, 10 Sep 2006 21:53:36 -0700 (PDT) Message-ID: Date: Mon, 11 Sep 2006 16:53:36 +1200 From: "Mike C" To: pgsql-admin@postgresql.org Subject: SELECT and DATE Function question MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_156645_6512629.1157950416635" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.551 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, HTML_10_20, HTML_MESSAGE, SPF_PASS X-Spam-Level: * X-Archive-Number: 200609/77 X-Sequence-Number: 22991 ------=_Part_156645_6512629.1157950416635 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I'm trying to calculate an expiration date by adding the number of days onto the start date. i.e. select start_date + number_of_days from blah; 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. What is the correct way to make this calculation? Cheers, Mike ------=_Part_156645_6512629.1157950416635 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi,

I'm trying to calculate an expiration date by adding the number of days onto the start date. i.e. select start_date + number_of_days from blah;

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.

What is the correct way to make this calculation?

Cheers,

Mike
------=_Part_156645_6512629.1157950416635--