bug in interval/extract or am I abusing interval()?

From: Chris Green <cmg(at)uab(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: bug in interval/extract or am I abusing interval()?
Date: 2001-10-29 18:01:26
Message-ID: m2d7369vgp.fsf@phosphorus.tucc.uab.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm using postgresql-7.1.3 and I'm trying to keep track of uptimes for
various devices by using an interval data type.

I've done some test cases and the way interval works with 'integer
seconds' is different from the way it acts with a raw int. I notice
that there is no interval(int) function.

How can one tell which function converted to?

* Seem the same but they are oddly different representations.

select interval(31900879);

interval
------------------------
1 year 4 days 05:21:19


select interval('31900879 seconds');

interval
-------------------
369 days 05:21:19

* Represenations really bite me here

select interval('31900879 seconds') - interval(31900879);
?column?
--------------------
-1 years +365 days

* more tests....

select extract(epoch from interval('31900879 seconds'));
date_part
-----------
31900879

select extract(epoch from interval(31900879));
date_part
-----------
31900879

test_network=# select extract(epoch from interval(31900879));
date_part
-----------
31922479
(1 row)

select extract(epoch from interval('31900879 seconds')) -
extract(epoch from interval(31900879));
?column?
----------
-21600

--
Chris Green <cmg(at)uab(dot)edu>
To err is human, to moo bovine.

Browse pgsql-general by date

  From Date Subject
Next Message Steve Wolfe 2001-10-29 18:03:29 Re: Running vacuum on cron
Previous Message Doug McNaught 2001-10-29 17:55:45 Re: Optimizing a complex query (long)