From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Absolute value of intervals |
Date: | 2009-11-02 11:39:29 |
Message-ID: | hcmgdh$55l$4@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2009-11-01, Lew <noone(at)lwsc(dot)ehost-services(dot)com> wrote:
> Tom Lane wrote:
>> Sam Mason <sam(at)samason(dot)me(dot)uk> writes:
>>> On Tue, Oct 27, 2009 at 11:27:17AM -0300, Joshua Berry wrote:
>>>> I couldn't find the operator '@' for intervals
>>
>>> A simple SQL implementation would look like:
>>
>>> CREATE FUNCTION absinterval(interval) RETURNS interval
>>> IMMUTABLE LANGUAGE sql AS 'SELECT greatest($1,-$1)';
>>> CREATE OPERATOR @ ( PROCEDURE = absinterval, RIGHTARG = interval );
>>
>>> or is a C version really needed?
>>
>> I think this came up again recently and somebody pointed out that the
>> correct definition isn't as obvious as all that. The components of
>> an interval can have different signs, so should abs('-1 day 1 hour') be
>> '1 day -1 hour' or '1 day 1 hour'? Or what about corner cases like
>> '1 day -25 hours'?
>
> I'm writing this at about 8:35 p.m. New York time on October 31, 2009. From
> now, adding interval '1 day -25 hours' yields right now, New York time.
>
This year halloween is the longest night. Interesting.
From | Date | Subject | |
---|---|---|---|
Next Message | Harald Fuchs | 2009-11-02 12:29:49 | Re: cidr data type question |
Previous Message | Jasen Betts | 2009-11-02 11:35:58 | Re: Absolute value of intervals |