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 1060F3A4061 for ; Mon, 25 Oct 2004 04:12:00 +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 12983-03 for ; Mon, 25 Oct 2004 03:11:55 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 268F63A405C for ; Mon, 25 Oct 2004 04:11:54 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i9P3BrhR009637; Sun, 24 Oct 2004 23:11:53 -0400 (EDT) To: Larry Lennhoff Cc: pgsql-sql@postgresql.org Subject: Re: Create interval using column value? In-reply-to: <6.0.2.0.0.20041024224504.03b5c7c8@localhost> References: <6.0.2.0.0.20041024224504.03b5c7c8@localhost> Comments: In-reply-to Larry Lennhoff message dated "Sun, 24 Oct 2004 22:54:33 -0400" Date: Sun, 24 Oct 2004 23:11:52 -0400 Message-ID: <9636.1098673912@sss.pgh.pa.us> From: Tom Lane 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/162 X-Sequence-Number: 19265 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