Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 75E9A9FB3A2 for ; Fri, 20 Apr 2007 17:11:11 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 95607-10 for ; Fri, 20 Apr 2007 17:11:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id C10F29FB372 for ; Fri, 20 Apr 2007 17:11:07 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Fri, 20 Apr 2007 20:11:06 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 20 Apr 2007 15:11:06 -0500 Subject: Re: Question on interval From: Scott Marlowe To: Wei Weng Cc: pgsql-sql@postgresql.org In-Reply-To: <46290C34.9080507@kencast.com> References: <46290C34.9080507@kencast.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1177099866.24411.30.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Fri, 20 Apr 2007 15:11:06 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/200 X-Sequence-Number: 28200 On Fri, 2007-04-20 at 13:53, Wei Weng wrote: > Hi all. > > How do I write a query that converts an interger to the interval type? > > Like convert integer 10 to INTERVAL '10 seconds'? > > The integer is a column in a table though, so it is more like convert > integer tbl.theInteger to INTERVAL 'tbl.theInteger seconds". A lot of the times, it's easiest to multiply it: select ..... where somedatefield > now() - interval '1 minute' * 5