pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jackson, DeJuan <djackson@cpsgroup.com>
To: Michael Olivier <michaelo@dnai.com>
To: pgsql-sql@postgreSQL.org
Subject: RE: [SQL] timespan question: using value from row in select
Date: Tue, 20 Oct 1998 09:46:03 -0500
Message-ID: <F10BB1FAF801D111829B0060971D839F489EF4@cpsmail> (raw)

> 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



view thread (2+ messages)

Message-ID: <F10BB1FAF801D111829B0060971D839F489EF4@cpsmail>
Permalink:  ../F10BB1FAF801D111829B0060971D839F489EF4@cpsmail/
Also on:    postgresql.org/message-id/F10BB1FAF801D111829B0060971D839F489EF4@cpsmail

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: djackson@cpsgroup.com, michaelo@dnai.com
  Subject: Re: [SQL] timespan question: using value from row in select
  In-Reply-To: <F10BB1FAF801D111829B0060971D839F489EF4@cpsmail>
  References: <F10BB1FAF801D111829B0060971D839F489EF4@cpsmail>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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