Re: Absolute value of intervals - Mailing list pgsql-general

From Sam Mason
Subject Re: Absolute value of intervals
Date
Msg-id 20091102130036.GG5407@samason.me.uk
Whole thread Raw
In response to Re: Absolute value of intervals  (Jasen Betts <jasen@xnet.co.nz>)
Responses Re: Absolute value of intervals  (Ron Mayer <rm_pg@cheapcomplexdevices.com>)
List pgsql-general
On Mon, Nov 02, 2009 at 10:52:40AM +0000, Jasen Betts wrote:
> what's the absolute value of '1month -30 days'::interval
>
> if I add it to the first of march it goes forwards if I add it to the
> first of february if goes backwards. if I add it to the first of april
> it goes nowhere.
>
>  select '2008-02-01'::date + '1month -30days'::interval;
>  select '2008-03-01'::date + '1month -30days'::interval;
>  select '2008-04-01'::date + '1month -30days'::interval;
>
> I'm guessing that '1 month 30 days' is the only mathematically
> consistent answer, not that it's likely to be useful.

Except that this is not consistent with itself.  Most definitions have
the absolute value of a number being the same as either the number
itself or its negation.

--
  Sam  http://samason.me.uk/

pgsql-general by date:

Previous
From: Sam Mason
Date:
Subject: Re: Absolute value of intervals
Next
From: Chris Barnes
Date:
Subject: 2009-11-02 08:31:30 EST:user@host(48990):4562ERROR: current transaction is aborted, commands ignored until end of transaction block