Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxyQt-0008DL-Hg for pgsql-sql@arkaria.postgresql.org; Wed, 23 Jan 2013 11:23:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TxyQs-0001Ii-IR for pgsql-sql@arkaria.postgresql.org; Wed, 23 Jan 2013 11:23:54 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxyQr-0001Ic-GB for pgsql-sql@postgresql.org; Wed, 23 Jan 2013 11:23:53 +0000 Received: from smtp-sofia.digsys.bg ([193.68.3.230]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxyQo-0007mf-V4 for pgsql-sql@postgresql.org; Wed, 23 Jan 2013 11:23:52 +0000 Received: from luke.digsys.bg (luke.digsys.bg [193.68.6.22]) by smtp-sofia.digsys.bg (8.14.5/8.14.5) with ESMTP id r0NBNjYY055470 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Wed, 23 Jan 2013 13:23:46 +0200 (EET) (envelope-from kaloyan@digsys.bg) Message-ID: <50FFC82A.3040305@digsys.bg> Date: Wed, 23 Jan 2013 13:23:22 +0200 From: Kaloyan Iliev Reply-To: kaloyan@digsys.bg User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130114 Thunderbird/17.0.2 MIME-Version: 1.0 CC: pgsql-sql@postgresql.org Subject: Re: Problem with extract(epoch from interval ... References: <50FFC180.80507@digsys.bg> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Thanks, It works perfectly. Regards, Kaloyan Iliev On 23.01.13 13:00, Ian Lawrence Barwick wrote: > Hi > > 2013/1/23 Kaloyan Iliev : >> Hi, >> I have a little problem with extract epoch from interval. It seems that the >> query works if the interval is in a string but not from DB field. >> Could someone provide support. > (...) > > You have a casting error; instead of: > >> dbr=# SELECT extract(EPOCH FROM INTERVAL b) FROM a; >> ERROR: syntax error at or near "b" >> LINE 1: SELECT extract(EPOCH FROM INTERVAL b) FROM a; > use > > SELECT extract(EPOCH FROM b::INTERVAL) FROM a; > > or > > > SELECT extract(EPOCH FROM CAST (b AS INTERVAL)) FROM a; > > > Regards > > Ian Barwick -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql