pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kaloyan Iliev <kaloyan@digsys.bg>
To: pgsql-sql@postgresql.org
Subject: Problem with extract(epoch from interval ...
Date: Wed, 23 Jan 2013 12:54:56 +0200
Message-ID: <50FFC180.80507@digsys.bg> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

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.
Thanks in advance.
  Best regards,
  Kaloyan Iliev

db=# begin;
BEGIN
db=# SELECT version();
version
-------------------------------------------------------------------------------------------------------------
  PostgreSQL 9.1.6 on amd64-portbld-freebsd9.1, compiled by cc (GCC) 
4.2.1 20070831 patched [FreeBSD], 64-bit
(1 row)

db=# SELECT EXTRACT(EPOCH FROM INTERVAL '3 months');
  date_part
-----------
    7776000
(1 row)

db=# CREATE TABLE a( b interval);
CREATE TABLE
db=# INSERT INTO  a  VALUES ('1 month');
INSERT 0 1
db=# INSERT INTO  a  VALUES ('3 month');
INSERT 0 1
db=#  INSERT INTO  a  VALUES ('6 month');
INSERT 0 1
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;



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (4+ messages)  latest in thread

Message-ID: <50FFC180.80507@digsys.bg>
Permalink:  ../50FFC180.80507@digsys.bg/
Also on:    postgresql.org/message-id/50FFC180.80507@digsys.bg

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: kaloyan@digsys.bg
  Subject: Re: Problem with extract(epoch from interval ...
  In-Reply-To: <50FFC180.80507@digsys.bg>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox