Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id D493E9FBA75 for ; Fri, 20 Apr 2007 16:35:28 -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 89466-02 for ; Fri, 20 Apr 2007 16:35:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mtao02.charter.net (mtao02.charter.net [209.225.8.187]) by postgresql.org (Postfix) with ESMTP id 1628B9FBA78 for ; Fri, 20 Apr 2007 16:35:24 -0300 (ADT) Received: from aa08.charter.net ([10.20.200.160]) by mtao02.charter.net (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070420193523.JFWH1398.mtao02.charter.net@aa08.charter.net>; Fri, 20 Apr 2007 15:35:23 -0400 Received: from [10.0.1.3] (really [66.188.171.190]) by aa08.charter.net with ESMTP id <20070420193523.KONJ10109.aa08.charter.net@[10.0.1.3]>; Fri, 20 Apr 2007 15:35:23 -0400 In-Reply-To: <46290C34.9080507@kencast.com> References: <46290C34.9080507@kencast.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <4AA02EED-0C35-4604-8881-3D3B26C351A9@seespotcode.net> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: Question on interval Date: Fri, 20 Apr 2007 14:35:29 -0500 To: Wei Weng X-Mailer: Apple Mail (2.752.2) X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/199 X-Sequence-Number: 28199 On Apr 20, 2007, at 13:53 , Wei Weng wrote: > How do I write a query that converts an interger to the interval type? > > Like convert integer 10 to INTERVAL '10 seconds'? An easy way to do this is: SELECT 10 * INTERVAL '1 second'; > > The integer is a column in a table though, so it is more like > convert integer tbl.theInteger to INTERVAL 'tbl.theInteger seconds". If you'd like to change the type of the column to interval, you can use something like ALTER TABLE a_table ALTER COLUMN an_integer_column TYPE INTERVAL USING an_integer_column * INTERVAL '1 second'; You could also create a view that would present the integer column as an interval if you don't want to alter the table itself. Does this help? Michael Glaesemann grzm seespotcode net