X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6A1715288E for ; Wed, 15 Jun 2005 16:03:22 -0300 (ADT) 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 74760-05 for ; Wed, 15 Jun 2005 19:03:17 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id CB32B52881 for ; Wed, 15 Jun 2005 16:03:16 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 515CE3095A; Wed, 15 Jun 2005 21:03:18 +0200 (MET DST) From: stig erikson X-Newsgroups: pgsql.docs Subject: Re: type casting reference? SOLVED Date: Wed, 15 Jun 2005 21:03:18 +0200 Organization: Hub.Org Networking Services Lines: 31 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511 X-Accept-Language: en-us, en, nn, nb, no, sv, pl In-Reply-To: To: pgsql-docs@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/29 X-Sequence-Number: 3122 stig erikson wrote: > hi. > i need to cast from timestamp to seconds (in the form of integer). > > i have a table with a column: > expiretime timestamp > > i have tried the following, it gives errors as below: > SELECT expiretime::float4 AS timeleft FROM table WHERE something='1234'; > ERROR: cannot cast type timestamp without time zone to real > > SELECT expiretime::text::float4 AS timeleft FROM table WHERE > something='1234'; > ERROR: invalid input syntax for type real: "2005-06-12 21:21:24.368082" > > > postgresql 7.4.1 (i know, old) > > so, my question is simply, where in the docs can i find how i should > perform the cast? > it would help a lot if there was a table showing which types can be > cased into which, and possibly an example or two for situations like > this, casting from timestamp (to timestamp worked right away). > > /stig solved my problem this way: UPDATE table SET expiretime= cast( ('now'::text)::timestamp+'30 minutes'::interval AS timestamp) WHERE sessionID='0';