From: Mark Dilger <pgsql@markdilger.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: [SQL] Interval subtracting
Date: Wed, 01 Mar 2006 13:21:36 -0800
Message-ID: <44061060.8080407@markdilger.com> (raw)
In-Reply-To: <15320.1141247469@sss.pgh.pa.us>
References: <200603012013.k21KDFM21139@candle.pha.pa.us>
<14834.1141244891@sss.pgh.pa.us>
<44060682.9020505@markdilger.com>
<15150.1141246521@sss.pgh.pa.us>
<44060C42.50905@markdilger.com>
<15320.1141247469@sss.pgh.pa.us>
Tom Lane wrote:
> Mark Dilger <pgsql@markdilger.com> writes:
>
>>The current code (without the patch) behaves as follows:
>
>
>> select justify_days(justify_hours('1 month 95 days -36:00:00'::interval));
>> justify_days
>> -------------------------
>> 4 mons 4 days -12:00:00
>
>
> So? If we liked the current behavior we wouldn't be discussing a patch...
>
> My thought is that justify_hours should reduce that input to
> '1 month 93 days 12:00:00' and then justify_days would produce
> '4 months 3 days 12:00:00'.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
Your proposal is that justify_hours borrows 24 hours from the days column in
order to bring the -12 hours up to a positive 12 hours. Should it only do that
if the days column is a positive number? What if it is negative?
I think we all agree on the following but nobody is explicitly saying so:
select justify_days(justify_hours('2 days -12:00:00'::interval))
justify_days
-------------------------
1 day 12:00:00
select justify_days(justify_hours('-2 days -12:00:00'::interval))
justify_days
-------------------------
-2 days -12:00:00
Am I correct that the second case should still have negative hours? If so, then
justify_hours(...) needs to examine the sign of the days and months portion of
the interval while performing its work.
mark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: pgsql@markdilger.com, tgl@sss.pgh.pa.us
Subject: Re: [SQL] Interval subtracting
In-Reply-To: <44061060.8080407@markdilger.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox