pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Larry Lennhoff <llennhoff-postgres@pexicom.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Create interval using column value?
Date: Sun, 24 Oct 2004 23:11:52 -0400
Message-ID: <9636.1098673912@sss.pgh.pa.us> (raw)
In-Reply-To: <6.0.2.0.0.20041024224504.03b5c7c8@localhost>
References: <6.0.2.0.0.20041024224504.03b5c7c8@localhost>

Larry Lennhoff <llennhoff-postgres@pexicom.com> writes:
> What I want to do is find all the rows in 
> A which were built before now() - build_interval seconds ago.  If I could 
> just write this in SQL it would look something like:

> SELECT A.id FROM A JOIN B ON (join_col) WHERE built_on < now() - interval 
> 'build_interval seconds';

You are confused about the difference between a literal constant and an
expression.   Try something like

... WHERE built_on < now() - build_interval * interval '1 second';

which relies on the number-times-interval operator.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <9636.1098673912@sss.pgh.pa.us>
Permalink:  ../9636.1098673912@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9636.1098673912@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, llennhoff-postgres@pexicom.com
  Subject: Re: Create interval using column value?
  In-Reply-To: <9636.1098673912@sss.pgh.pa.us>

* 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