Re: Absolute value of intervals

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-10-27 14:49:44
Message-ID: 20091027144944.GK5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-10-27 14:55:31 Re: Absolute value of intervals
Previous Message Raimon Fernandez 2009-10-27 14:43:20 Re: Implementing Frontend/Backend Protocol TCP/IP