Re: Absolute value of intervals

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:35:58
Message-ID: hcmg6u$55l$3@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2009-10-27, Joshua Berry <yoberi(at)gmail(dot)com> wrote:
> I couldn't find the operator '@' for intervals and found this thread
> from over six years ago:
> http://archives.postgresql.org/pgsql-general/2003-09/msg00292.php
>
>| "Claudio Lapidus" <clapidus(at)hotmail(dot)com> writes:
>| > Bruce Momjian wrote:
>| >> Why would you want an abolute value of a negative interval?
>|
>| > Because I'm trying to match pairs of records that satisfy certain criteria,
>|
>| Given that we have a unary-minus operator for intervals, I see no
>| conceptual objection to having an absolute-value operator (and \do shows
>| that interval is the only standard datatype that has the former but not
>| the latter).
>|
>| However, given that it doesn't seem to be a really widely useful
>| operator, I think this is the kind of itch that you'll have to scratch
>| yourself. Send us a patch and it'll get into the next release ...
>|
>| regards, tom lane
>
> Is this is the case now? I have some data that is related but requires
> fuzzy joining on timestamps within a time interval.
>
> I'd like to be able to do this:
> select * from enviados e, recibidos r where @ (e.fecha - r.fecha) <
> interval '1 second'

for this case: convert to seconds and then do abs.

select * from enviados e, recibidos r where abs(extract ( epoch from
(e.fecha - r.fecha) )) < 1

thanks for sparking an interesting discussion.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jasen Betts 2009-11-02 11:39:29 Re: Absolute value of intervals
Previous Message Jasen Betts 2009-11-02 11:22:00 Re: Absolute value of intervals