Re: tinterval or interval

Поиск
Список
Период
Сортировка
От Mike Castle
Тема Re: tinterval or interval
Дата
Msg-id 20001124172053.A1011@thune.mrc-home.org
обсуждение исходный текст
Ответ на Re: tinterval or interval  (Mike Castle <dalgoda@ix.netcom.com>)
Список pgsql-novice
On Fri, Nov 24, 2000 at 02:52:31PM -0600, Mike Castle wrote:
> Am I missing something in the documentation that would explain to me how I
> could use a starttime/length combination (something like abstime/interval,
> or timestamp/interval) to check for overlaps like can be done with tinterval?

Ok.  Apparently it's time to invest in a good SQL book before proceeding.
I did a web search and found SQL specs online (well, not the final
versions, but probably close enough).

And I figured out how to use the overlaps operator:

test=# select ('2000-11-21 08:00'::timestamp, '2000-11-21 09:00'::timestamp)
 overlaps ('2000-11-21 08:59'::timestamp, '2000-11-21 10:00'::timestamp);

 overlaps
----------
 t
(1 row)


Probably an easier way to write that, but in the mean time....

I have noticed a difference between how overlaps work compared to && for
tinterval.  With tinterval [8:00-9:00] is considered to overlap with
[9:00-10:00], while with overlaps, they don't:

test=# select tinterval '["2000-11-21 08:00" "2000-11-21 09:00"]' &&
tinterval '["2000-11-21 09:00" "2000-11-21 10:00"]';
 ?column?
----------
 t
(1 row)

test=# select ('2000-11-21 08:00'::timestamp, '2000-11-21 09:00'::timestamp)
 overlaps ('2000-11-21 09:00'::timestamp, '2000-11-21 10:00'::timestamp);
 overlaps
----------
 f
(1 row)

Since I don't yet have a good book.... should that be considered to overlap
or not?  My initial thoughts were that tinterval and timestamps/overlaps
would have the same semantics.

mrc
--
       Mike Castle       Life is like a clock:  You can work constantly
  dalgoda@ix.netcom.com  and be right all the time, or not work at all
www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen

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

Предыдущее
От: Mike Castle
Дата:
Сообщение: Re: tinterval or interval
Следующее
От: Laurent HERVE
Дата:
Сообщение: Strange error with Pl/PgSQL