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 7B5A152834 for ; Sun, 12 Jun 2005 16:39:13 -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 60263-09 for ; Sun, 12 Jun 2005 19:39:04 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 45F6752819 for ; Sun, 12 Jun 2005 16:39:03 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id E739A30E8A; Sun, 12 Jun 2005 21:39:03 +0200 (MET DST) From: stig erikson X-Newsgroups: pgsql.docs Subject: type casting reference? Date: Sun, 12 Jun 2005 21:39:28 +0200 Organization: Hub.Org Networking Services Lines: 23 Message-ID: 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 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/28 X-Sequence-Number: 3121 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