RE: [SQL] timespan question: using value from row in select

From: "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com>
To: Michael Olivier <michaelo(at)dnai(dot)com>, pgsql-sql(at)postgreSQL(dot)org
Subject: RE: [SQL] timespan question: using value from row in select
Date: 1998-10-20 14:46:03
Message-ID: F10BB1FAF801D111829B0060971D839F489EF4@cpsmail
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> Hi folks,
>
> I'm trying to write a SELECT statement that uses a min_age column
> (integer expressing a number of years) as part of a timespan:
>
> select * from users U where
> age('now', '01-01-1970') >= timespan('U.min_age years'::timespan);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
try:
SELECT * FROM users U WHERE
AGE('now', '1/1/1997') >= (U.min_age::text || ' years')::timespan;

> ERROR: parser: parse error at or near "error"
>
>
> Is there some way to do this? I want to convert an int expressing
> years
> into a timespan, within a select statement.
>
> Thanks for any insights on how to do this.
>
> --Michael

Browse pgsql-sql by date

  From Date Subject
Next Message Howie 1998-10-20 16:59:49 count(*) and group by's...
Previous Message Pascal Forget 1998-10-20 14:01:14 Index on VARCHAR faster than TEXT?