Re: Absolute value of intervals

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: Absolute value of intervals
Дата
Msg-id hcmdlo$4tc$1@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на Absolute value of intervals  (Joshua Berry <yoberi@gmail.com>)
Ответы Re: Absolute value of intervals  (Sam Mason <sam@samason.me.uk>)
Re: Absolute value of intervals  (CaT <cat@zip.com.au>)
Список pgsql-general
On 2009-10-27, Joshua Berry <yoberi@gmail.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@hotmail.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.

what's the absolute value of '1month -30 days'::interval

if I add it to the first of march it goes forwards if I add it to the
first of february if goes backwards. if I add it to the first of april
it goes nowhere.

 select '2008-02-01'::date + '1month -30days'::interval;
 select '2008-03-01'::date + '1month -30days'::interval;
 select '2008-04-01'::date + '1month -30days'::interval;

I'm guessing that '1 month 30 days' is the only mathematically
consistent answer, not that it's likely to be useful.




"People don't understand time, it's not what you think it is"
...
"It's more like a big ball of wibbly wobbly timey wimely stuff" - Dr Who.
("Blink")


В списке pgsql-general по дате отправления:

Предыдущее
От: Ivan Sergio Borgonovo
Дата:
Сообщение: pk vs unique not null differences between 8.3.4 and 8.3.8
Следующее
От: Jasen Betts
Дата:
Сообщение: Re: Absolute value of intervals