Problem with date calculations - Mailing list pgsql-general

From Cornelia Boenigk
Subject Problem with date calculations
Date
Msg-id 006301c3d7ca$2c43eac0$0201a8c0@zwerg2000
Whole thread Raw
In response to Hierarchical queries  (Anton.Nikiforov@loteco.ru)
Responses Re: Problem with date calculations  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-general
Hi alltogether

I have a table with two fields, d1 timestamp and dur smallint.
d1 is the starting date and dur is the duration. From this two fields
I want to generate future dates for the whole table.
There is no problem with queries where a number for the duration is
given.

test=# select d1,dur,d1 + '6 month' from t1;
            d1                   |  dur  |      ?column?
-----------------------+-----+---------------------
 2003-12-27 00:00:00 |      4 | 2004-06-27 00:00:00
 2003-11-14 00:00:00 |      7 | 2004-05-14 00:00:00
 2004-01-03 00:00:00 |      5 | 2004-07-03 00:00:00

I want to have the date plus the duration stored in the table, but
didn't succeed.

test=# select '\''||dur::varchar||' month\'' from t1;
 ?column?
-----------
 '4 month'
 '7 month'
 '5 month'

but

test=# select d1 + '\''||wielange::varchar||' month\'' from t1;
ERROR:  invalid input syntax for type interval: "'"

Any hints are welcome

Regards
Conni


pgsql-general by date:

Previous
From: "D. Dante Lorenso"
Date:
Subject: Bug with rename bigserial column
Next
From: Stephan Szabo
Date:
Subject: Re: Problem with date calculations