pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
timespan question: using value from row in select
2+ messages / 2 participants
[nested] [flat]

* timespan question: using value from row in select
@ 1998-10-20 01:18  Michael Olivier <michaelo@dnai.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Olivier @ 1998-10-20 01:18 UTC (permalink / raw)
  To: pgsql-sql; +Cc: michaelo@dnai.com

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);
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* RE: [SQL] timespan question: using value from row in select
@ 1998-10-20 14:46  Jackson, DeJuan <djackson@cpsgroup.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Jackson, DeJuan @ 1998-10-20 14:46 UTC (permalink / raw)
  To: Michael Olivier <michaelo@dnai.com>; 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1998-10-20 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-10-20 01:18 timespan question: using value from row in select Michael Olivier <michaelo@dnai.com>
1998-10-20 14:46 RE: [SQL] timespan question: using value from row in select Jackson, DeJuan <djackson@cpsgroup.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox