Re: [SQL] Interval subtracting

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Mark Dilger <pgsql(at)markdilger(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [SQL] Interval subtracting
Date: 2006-03-01 18:24:28
Message-ID: 20060301182428.GF82012@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches pgsql-sql

On Wed, Mar 01, 2006 at 12:59:29PM -0500, Bruce Momjian wrote:
> Good question. Should we restrict days to 0 - 30 or -30 - 30? The
> current system does the later:
>
> test=> select justify_days('-45 days');
> justify_days
> ------------------
> -1 mons -15 days
> (1 row)
>
> test=> select justify_days('1 month -45 days');
> justify_days
> --------------
> -15 days
> (1 row)
>
> test=> select justify_days('1 month -15 days');
> justify_days
> ----------------
> 1 mon -15 days
> (1 row)
>
> Should we be adjusting the last one? I am unsure. Comments?

ISTM it should be looking at the sign of the overall interval, and
sticking with that consistently. So while '1 mon 5 days' and '-3 mon -8
days' both make sense, '1 mon -2 days' doesn't make nearly as much sense
in the general case. Of course this is complicated by the fact that '1
mon 20 days' doesn't necessarily equate to '2 mon -10 days'... :(

One of these days we should just create a new calendar. ;)
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2006-03-01 18:31:44 Re: Looking for a tool to "*" pg tables as ERDs
Previous Message Mark Dilger 2006-03-01 18:06:37 Re: [SQL] Interval subtracting

Browse pgsql-patches by date

  From Date Subject
Next Message Mark Dilger 2006-03-01 18:39:58 Re: [SQL] Interval subtracting
Previous Message Mark Dilger 2006-03-01 18:06:37 Re: [SQL] Interval subtracting

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2006-03-01 18:28:03 Re: Replication - state of the art?
Previous Message Andrew Sullivan 2006-03-01 18:23:45 Re: Help with trigger that updates a row prior to a potentially aborted deletion?