Help with syntax for timestamp addition

From: Scott Nixon <snixon(at)lssi(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Help with syntax for timestamp addition
Date: 2004-11-22 13:55:50
Message-ID: 1101131750.23253.1.camel@talon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

New to Postgres 7.3 from 7.0.

Am having some trouble with a query that worked in 7.0 but not in
7.3.....can't seem to figure out the syntax or find info about how to do
this anywhere.

Consider for the following query:
- 'number' is an integer
- 'procedures' is the table name
- 'date' is a timestamp
- 'numdays' is an integer

SELECT number
FROM procedures
WHERE date + numdays <= CURRENT_TIMESTAMP;

In 7.0 this works with no problem...finding all rows where the date plus
some number of days is less than the current. But in 7.3 I get:

ERROR: Unable to identify an operator '+' for types 'timestamp without
time zone' and 'integer'
You will have to retype this query using an explicit cast

I've never had to create casts before so I'm not too sure how to work
this casting into the query....keep getting various syntax errors no
matter what I try. If I try to incorporate intervals, I also get errors.
I just can't seem to find good examples in any documentation.

Any help is appreciated.

-Scott

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey 2004-11-22 13:59:30 Re: How to handle larger databases?
Previous Message Oleg Bartunov 2004-11-22 13:48:15 Re: Tsearch2 and Unicode?