BUG #1066: avg(age()) results months with more than 30 days

From: "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1066: avg(age()) results months with more than 30 days
Date: 2004-01-25 09:20:18
Message-ID: 20040125092018.D392ACF4A30@www.postgresql.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1066
Logged by: Beda Szukics

Email address: beda(at)muri-gries(dot)ch

PostgreSQL version: 7.3.4

Operating system: linux

Description: avg(age()) results months with more than 30 days

Details:

Hello all

When I try to calculate the average age of the following birthdates I get
months with more than 30 days. Is this a bug?

I use version 7.3.4

These are the birthdates:

kongregation=> SELECT geb_dat FROM personen;
geb_dat
------------
20.12.1946
29.01.1948
21.03.1933
07.01.1954
22.08.1959
07.07.1913
30.11.1922
29.08.1925
07.01.1927
06.07.1928
25.09.1928
23.05.1929
25.04.1930
27.03.1933
21.12.1933
28.03.1937
03.02.1940
13.12.1941
13.02.1942
30.04.1937
25.08.1943
03.06.1964
26.01.1956
04.11.1957
27.12.1961
22.03.1911
30.11.1918
02.05.1957
08.03.1925
(29 rows)

Today (20.1.2004 german style) I get the answer:

kongregation=> SELECT AVG(AGE(geb_dat)) FROM personen ;
avg
------------------------------------
@ 65 years 9 mons 4 days 0.00 secs
(1 row)

Yesterday and the day before yesterday I got:

kongregation=> SELECT AVG(AGE('19.01.2004',geb_dat)) FROM personen ;
avg
------------------------------------------------------
@ 65 years 8 mons 32 days 2 hours 28 mins 57.93 secs
(1 row)

kongregation=> SELECT AVG(AGE('20.01.2004',geb_dat)) FROM personen ;
avg
-----------------------------------------------------
@ 65 years 8 mons 33 days 1 hour 39 mins 18.62 secs
(1 row)

BTW: I think having the result with years and days only would be a better
answer, what kind of months are counted in the present form?

Greetings Beda

Browse pgsql-bugs by date

  From Date Subject
Next Message Kris Jurka 2004-01-26 13:22:34 Re: BUG #1065: JDBC DataSource Serializability
Previous Message Tom Lane 2004-01-25 02:45:51 Re: Should Aggregate Functions always return one row?