Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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);

(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"]';
(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);
(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.

       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 and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen

In response to

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group