Re: tinterval or interval

From: Mike Castle <dalgoda(at)ix(dot)netcom(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Cc: Mike Castle <dalgoda(at)ix(dot)netcom(dot)com>
Subject: Re: tinterval or interval
Date: 2000-11-24 23:20:53
Message-ID: 20001124172053.A1011@thune.mrc-home.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)ix(dot)netcom(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Laurent HERVE 2000-11-25 13:08:54 Strange error with Pl/PgSQL
Previous Message Mike Castle 2000-11-24 20:52:31 Re: tinterval or interval