Hi, I see followings in current:

create table t2 (t date primary key)
[insert some data into t2]
 select *,age(t) from t2 where age(t) = '9 mons 30 days'::interval;
     t      |      age       
------------+----------------
 2001-03-18 | 10 mons
 2001-03-19 | 9 mons 30 days
(2 rows)

How come 10 mons == 9 mons 30 days?
--
Tatsuo Ishii

Fri, 18 Jan 2002 13:47:45 +0900
Tatsuo Ishii <t-ishii@sra.co.jp>
age() function?
Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> How come 10 mons == 9 mons 30 days?

Because for purposes of comparisons, type interval assumes 1 month
== 30 days (cf. interval_cmp_internal).  Pretty grotty, I agree,
but it's not easy to see how to do better.

			regards, tom lane

Fri, 18 Jan 2002 00:11:12 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: age() function? 
> > How come 10 mons == 9 mons 30 days?
> 
> Because for purposes of comparisons, type interval assumes 1 month
> == 30 days (cf. interval_cmp_internal).  Pretty grotty, I agree,
> but it's not easy to see how to do better.

Oh I see. Probably that's the reason why the standard does not allow
month-and-day-mixed interval.
--
Tatsuo Ishii

Fri, 18 Jan 2002 14:38:57 +0900
Tatsuo Ishii <t-ishii@sra.co.jp>
Re: age() function? 
Tom Lane wrote:
> Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> > How come 10 mons == 9 mons 30 days?
> 
> Because for purposes of comparisons, type interval assumes 1 month
> == 30 days (cf. interval_cmp_internal).  Pretty grotty, I agree,
> but it's not easy to see how to do better.

I guess if we knew the month we could do better.  :-)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Fri, 18 Jan 2002 00:54:09 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: age() function?
> > > How come 10 mons == 9 mons 30 days?
> > Because for purposes of comparisons, type interval assumes 1 month
> > == 30 days (cf. interval_cmp_internal).  Pretty grotty, I agree,
> > but it's not easy to see how to do better.
> Oh I see. Probably that's the reason why the standard does not allow
> month-and-day-mixed interval.

Right. I have it fall back to a fixed 30 days. Seems better than
disallowing it altogether...

                 - Thomas

Fri, 18 Jan 2002 07:23:41 +0000
Thomas Lockhart <lockhart@fourpalms.org>
Re: age() function?