Iï¿½m making tests for data types and I wonder if the following  is a bug!

using age() function I get: @ 1 hour 13 mins 27.88 secs
using date_part() over age() I get:

1 for 'hour'   OK!
13 for 'minute'   OK!
27.8765430000003  for 'second'   OK!
0 for 'day'   OK!
0 for 'month'   OK!
0 for 'year'   OK!

But

1 for 'decade'     NOT OK!
1 for 'century'    NOT OK!
1 for 'millenium'    NOT OK!

See trancrition bellow

cd=> \d th

Table    =
th
+----------------------------------+----------------------------------+--
-----+
|              Field               |              Type
 |
Length|
+----------------------------------+--------------------------------
--+-------+
| data                             | date
      |     4 |
| hora                             | time
          |     8 |
| ms                               | int4
              |     4 |
| dt                               | datetime
                  |     8
|
+----------------------------------+----------------------------------+---
----+
cd=> select * from th
cd-> \g
data      |hora    |        ms|dt


----------+--------+----------+--------------------------
11/02/1999|10:33:
31|1234567890|11/02/1999 10:33:31.12
EDT
11/02/1999|10:33:31|1234567890|11/02/1999 10:33:31.13 EDT
(2
rows)

cd=>   select age('now', dt)   , date_part('millenium', age('now',
dt)::timespan), date_part('century', age('now', dt)::timespan),
date_part('decade', age('now', dt)::timespan) , date_part('year',
age('now', dt)::timespan), date_part('month', age('now', dt)::timespan),
date_part('day', age('now', dt)::timespan) , date_part('hour', age('now',
dt)::timespan)  , date_part('minute', age('now', dt)::timespan) ,
date_part('second', age('now', dt)::timespan) from th\g
age

|date_part|date_part|date_part|date_part|date_part|date_part|date_part|date_
part|
date_part
---------------------------+---------+---------+---------+--------
-+---------+---------+---------+---------+----------------
@ 1 hour 13 mins
27.88 secs|        1|        1|        1|        0|        0|        0|
   1|       13|27.8765430000003
@ 1 hour 13 mins 27.87 secs|        1|
  1|        1|        0|        0|        0|        1|
13|27.8654319999996
(2 rows)

cd=> 

------------------------------------------------------------------
Eng. Roberto Joï¿½o Lopes Garcia         E-mail: roberto@mha.com.br
F. 55 11 848 9906   FAX  55 11 848 9955

MHA Engenharia Ltda
E-mail: mha@mha.com.br    WWW: http://www.mha.com.br

Av Maria Coelho Aguiar, 215 Bloco D     2 Andar
Centro Empresarial de Sao Paulo
Sao Paulo - BRASIL - 05805 000
-------------------------------------------------------------------


Thu, 11 Feb 1999 14:26:12 -0200
Roberto Joao Lopes Garcia <roberto@mha.com.br>
date_part() BUG?
> Iï¿½m making tests for data types and I wonder if the following  is a 
> bug!
> using age() function I get: @ 1 hour 13 mins 27.88 secs
> using date_part() over age() I get:
<snip tests for years through seconds>
> But
> 1 for 'decade'     NOT OK!
> 1 for 'century'    NOT OK!
> 1 for 'millenium'    NOT OK!

I can see that here. Will look at it. Thanks for the report...

                  - Tom

Thu, 11 Feb 1999 17:08:59 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [HACKERS] date_part() BUG?
> > using age() function I get: @ 1 hour 13 mins 27.88 secs
> > using date_part() over age() I get:
> <snip tests for years through seconds>
> > But
> > 1 for 'decade'     NOT OK!
> > 1 for 'century'    NOT OK!
> > 1 for 'millenium'    NOT OK!
> I can see that here. Will look at it. Thanks for the report...

Sorry, it was a cut-and-paste error, with an explicit "+ 1" where it
shouldn't be. Patch enclosed, which includes another recent fix for date
input having mixed US/Euro-style formats and text months. If you've
already applied that one, then strip it out of the patch before applying
(or tell patch the right thing when it complains).

Thanks again for the report.

                    - Tom
Thu, 11 Feb 1999 17:38:12 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [HACKERS] date_part() BUG?