Re: [SQL] Interval subtracting

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Hannu Krosing <hannu(at)skype(dot)net>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Milen A(dot) Radev" <milen(at)radev(dot)net>, pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [SQL] Interval subtracting
Date: 2006-03-01 20:32:42
Message-ID: 20060301123127.D11836@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches pgsql-sql

On Wed, 1 Mar 2006, Hannu Krosing wrote:

> Ühel kenal päeval, K, 2006-03-01 kell 15:18, kirjutas Bruce Momjian:
> > Stephan Szabo wrote:
> > > > justify_days doesn't currently do anything with this result --- it
> > > > thinks its charter is only to reduce day components that are >= 30 days.
> > > > However, I think a good case could be made that it should normalize
> > > > negative days too; that is, the invariant on its result should be
> > > > 0 <= days < 30, not merely days < 30.
> > >
> > > What about cases like interval '1 month -99 days', should that turn into
> > > interval '-3 mons +21 days' or '-2 mons -9 days'?
> >
> > I think it should be the later. It is best to have a single sign, and I
> > think it is possible in all cases:
> >
> > '2 mons -1 days'
> >
> > could be adjusted to '1 mons 29 days'.
>
> But unfortunately '2 mons -1 days' <> '1 mons 29 days'
>
> If I want something to happen 1 day less than two months from dome date,
> then the only way to say that consistently *is* '2 mons -1 days'.

Right, but would you call justify_days on such an interval? '2 months -1
days' <> '1 mon 29 days', but '1 mon 60 days' is also <> '3 mons' in
general usage.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-03-01 20:33:22 Re: [SQL] Interval subtracting
Previous Message Hannu Krosing 2006-03-01 20:28:39 Re: [SQL] Interval subtracting

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2006-03-01 20:33:22 Re: [SQL] Interval subtracting
Previous Message Hannu Krosing 2006-03-01 20:28:39 Re: [SQL] Interval subtracting

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2006-03-01 20:33:22 Re: [SQL] Interval subtracting
Previous Message Hannu Krosing 2006-03-01 20:28:39 Re: [SQL] Interval subtracting