X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 970D03A4069 for ; Mon, 25 Oct 2004 04:19:12 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14484-06 for ; Mon, 25 Oct 2004 03:19:03 +0000 (GMT) Received: from smtp.bltconsult.com (smtp.bltconsult.com [64.124.68.186]) by svr1.postgresql.org (Postfix) with ESMTP id 7F0923A4076 for ; Mon, 25 Oct 2004 04:19:03 +0100 (BST) Received: from [138.89.132.102] (helo=LENNHOFF-PEXI.foo.bar) by 64.125.181.59 with asmtp (TLSv1:RC4-SHA:128) id 1CLvNm-0003Sh-00; Sun, 24 Oct 2004 23:18:54 -0400 Message-Id: <6.0.2.0.0.20041024231819.03b5c540@localhost> Date: Sun, 24 Oct 2004 23:18:55 -0400 To: Tom Lane From: Larry Lennhoff Subject: Re: Create interval using column value? Cc: pgsql-sql@postgresql.org In-Reply-To: <9636.1098673912@sss.pgh.pa.us> References: <6.0.2.0.0.20041024224504.03b5c7c8@localhost> <9636.1098673912@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/164 X-Sequence-Number: 19267 Thanks, that was exactly what I needed. Larry ]At 11:11 PM 10/24/2004, Tom Lane wrote: >Larry Lennhoff 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