Re: Create interval using column value? - Mailing list pgsql-sql

From Tom Lane
Subject Re: Create interval using column value?
Date
Msg-id 9636.1098673912@sss.pgh.pa.us
Whole thread Raw
In response to Create interval using column value?  (Larry Lennhoff <llennhoff-postgres@pexicom.com>)
Responses Re: Create interval using column value?
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Larry Lennhoff
Date:
Subject: Create interval using column value?
Next
From: Michael Glaesemann
Date:
Subject: Re: Create interval using column value?