Re: '1 year' = '360 days' ???? - Mailing list pgsql-general

From Tom Lane
Subject Re: '1 year' = '360 days' ????
Date
Msg-id 4333.1098581895@sss.pgh.pa.us
Whole thread Raw
In response to Re: '1 year' = '360 days' ????  (Doug McNaught <doug@mcnaught.org>)
Responses Re: '1 year' = '360 days' ????  (Bruno Wolff III <bruno@wolff.to>)
Re: '1 year' = '360 days' ????  (Guy Fraser <guy@incentre.net>)
List pgsql-general
Doug McNaught <doug@mcnaught.org> writes:
> template1=# select '1 year'::interval = '360 days'::interval;
>  ?column?
> ----------
>  t
> (1 row)

Yeah, if you look at interval_cmp_internal() it's fairly obvious why.
I think that this definition is probably bogus, and that only intervals
that match exactly (equal months parts *and* equal seconds parts) should
be considered "equal".  However the most obvious way to redefine it
(compare the months, and only if equal compare the seconds) would lead
to rather nonintuitive behaviors such as "'1 year' > '1000 days'".
Anybody have any thoughts about a better way to map the multicomponent
reality into a one-dimensional sorting order?

(Note also that as Bruno was just mentioning, we really ought to have
months/days/seconds components, not just months/seconds; which makes the
comparison issue even more interesting.)

            regards, tom lane

pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: how to port Oracle database to PostgreSQL?
Next
From: Bruno Wolff III
Date:
Subject: Re: '1 year' = '360 days' ????