date_part returns different results with same interval. - Mailing list pgsql-bugs

From Wade Klaver
Subject date_part returns different results with same interval.
Date
Msg-id 200402191652.37148.archeron@wavefire.com
Whole thread Raw
Responses Re: date_part returns different results with same interval.
List pgsql-bugs
Hello folks.

I just noticed some funky behaviour on the part of date_part.  If there is
some reason this is correct behaviour, I wouldn't mind knowing why.
The problem is that date_part can return different results given to
essentially identical intervals.  It seems to maybe be obeying the letter of
the law if not the spirit? The following session from a -CURRENT build
demonstrates this.
Thanks in advance.

wade=# select age(now(), 'Jan 1, 2002'::date);
                    age
-------------------------------------------
 2 years 1 mon 18 days 16:24:54.4191970001
(1 row)

wade=# select date_part( 'years', age(now(), 'Jan 1, 2002'::date));
 date_part
-----------
         2
(1 row)

wade=# select now() - 'Jan 1, 2002'::date;
           ?column?
------------------------------
 779 days 16:25:03.9250539988
(1 row)

wade=# select date_part( 'years', now() - 'Jan 1, 2002'::date);
 date_part
-----------
         0
(1 row)


--
Wade Klaver
Wavefire Technologies Corporation
GPG Public Key at http://archeron.wavefire.com

/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
 X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------

pgsql-bugs by date:

Previous
From: wade
Date:
Subject:
Next
From: Laurent FAILLIE
Date:
Subject: Re: zlib directory in configure.