Can interval take a value from a field?

From: Jeff Ross <jross(at)wykids(dot)org>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Can interval take a value from a field?
Date: 2008-09-09 23:03:15
Message-ID: 48C700CA.5080502@wykids.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sometimes I think the hurdle to learning more advanced sql is figuring
out how to phrase the search question. Well, I'm not having any luck
there so here I come again to the list, hat in hand :-)

I have a table with an id key and an expiration value in years

trgexpd_trg_id | expiration_value
----------------+------------------
240 | 1 year
749 | 3 years
4917 | 2 years

and so on.

I'm trying to use the expiration value as the value for an interval in a
query that looks like:

select
ts_date as "Transcript Date",
ts_expiration_date as "Current Expiration Date",
expiration_value as "Expiration Interval"
from transcript, training_expiration_value where
ts_training_id = trgexpd_trg_id and
ts_training_id in (select cda_training_number from cdas) and
ts_expiration_date != ts_date + interval 'expiration_value';

and I'm getting the following error:

ERROR: invalid input syntax for type interval: "expiration_value"

Is there a way to use the value in expiration_value for the interval?

Thanks,

Jeff Ross

Responses

Browse pgsql-general by date

  From Date Subject
Next Message justin 2008-09-09 23:12:18 Re: Automated Backup On Windows
Previous Message cyw 2008-09-09 22:44:43 syntax error on: GET DIAGNOSTICS xcount = ROW_COUNT;