Received: from myst.fourpalms.org (myst.jpl.nasa.gov [137.78.15.105]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3BMOq875077 for ; Wed, 11 Apr 2001 18:24:52 -0400 (EDT) (envelope-from lockhart@alumni.caltech.edu) Received: from alumni.caltech.edu (localhost.localdomain [127.0.0.1]) by myst.fourpalms.org (Postfix) with ESMTP id ECF26C52B; Wed, 11 Apr 2001 21:26:21 +0000 (UTC) Message-ID: <3AD4CBFD.AD3FD301@alumni.caltech.edu> Date: Wed, 11 Apr 2001 21:26:21 +0000 From: Thomas Lockhart Organization: Yes X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.17-21mdk i686) X-Accept-Language: en MIME-Version: 1.0 To: Peter Eisentraut Cc: lockhart@fourpalms.org, Hackers List Subject: Re: age() function documentation References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200104/391 X-Sequence-Number: 7372 > As you see in one of the examples I posted, it does not preserve years and > months. What exactly does that mean anyway? Simple subtraction also > preserves years and months, as I see it. OK, so there is a documentation problem, since the functions do exactly what they claim! What do you mean by "it does not preserve years and months"? I look at the same example, and run the same example here, and it does exactly what I would expect, in the way I described it in the docs ;) > > Would we like some additional clarification in the docs perhaps? Seems > > to be preferable to dropping all mention, especially since it is a > > useful function. > By all means. OK, I'll add some info. But assuming that we are just missing a clear definition of what "preserves years and months" means, here it is: Typical date/time arithmetic resolves to an absolute time or interval. In those cases, *qualitative* quantities such as years and months are resolved to a specific absolute interval at the time of calculation. The age() functions *preserve* the qualitative fields year and month. So you see the difference in results: lockhart=# select age('today', '1957-06-13'); ------------------------- 43 years 9 mons 28 days lockhart=# select timestamp 'today' - timestamp '1957-06-13'; ------------ 16008 days In the case for the DATE type, the result is an integer value (not an interval) which I believe was done intentionally but I'm not recalling exactly why; I can research it if necessary: lockhart=# select date 'today' - date '1957-06-13'; ---------- 16008 returns the number of days (which is also an absolute, quantitative time). - Thomas