From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Mark Dilger <pgsql@markdilger.com>
Cc: pgsql-hackers@postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: [SQL] Interval subtracting
Date: Wed, 1 Mar 2006 15:13:15 -0500 (EST)
Message-ID: <200603012013.k21KDFM21139@candle.pha.pa.us> (raw)
In-Reply-To: <4405E2AD.6030404@markdilger.com>
Mark Dilger wrote:
> select justify_hours('-73 hours'::interval);
> justify_hours
> -------------------
> -4 days +23:00:00
>
> select justify_days('-62 days'::interval);
> justify_days
> ------------------
> -3 mons +28 days
>
>
> I find the last two results somewhat peculiar, as the new functionality
> pushes the negative values upwards (from hours to days, days to months).
> Changing '-73 hours' to '-3 days -1 hour' might be more intuitive?
> The '-4 days +23 hours' is however consistent with the behavior in the
> other cases.
I don't think we can accept a change that takes a negative and turns it
into a positive and negative. I think the answer to the last one should
be '-2 mons -2 days', which is what it does now:
test=> select justify_days('-62 days'::interval);
justify_days
-----------------
-2 mons -2 days
(1 row)
The open question is whether we should convert a positive and negative
to a positive, or a negative, based on the sign of the highest value,
e.g. convert '1 mons -10 days' to '20 days', and '-1 mons 10 days' to
'-20 days'?
--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com
+ If your life is a hard drive, Christ can be your backup. +
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: pgman@candle.pha.pa.us, pgsql@markdilger.com, tgl@sss.pgh.pa.us
Subject: Re: [SQL] Interval subtracting
In-Reply-To: <200603012013.k21KDFM21139@candle.pha.pa.us>
* 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