| From: | Sam Mason <sam(at)samason(dot)me(dot)uk> | 
|---|---|
| To: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Absolute value of intervals | 
| Date: | 2009-11-02 13:00:37 | 
| Message-ID: | 20091102130036.GG5407@samason.me.uk | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | CaT | 2009-11-02 13:53:35 | Re: Absolute value of intervals | 
| Previous Message | Sam Mason | 2009-11-02 12:47:46 | Re: Absolute value of intervals |