Re: date overlap
Date: Wed, 20 Dec 2000 05:10:11 GMT
Message-ID: <91pevi$8ad$1_at_nnrp1.deja.com>
[Quoted] In article <hJV%5.14235$bw.1170406_at_news.flash.net>,
"Eric Givler" <egivler_at_flash.net> wrote:
> What's the quickest/most efficient way to check for an overlapping
date
> range in a SQL statement?
>
> Table A:
> blocked areas
> area_eid number
> start_date date
> end_date date
>
> Table B:
> Reservation
> Area_eid number
> arrival_date date
> departure_date date
>
> I don't want to allow reservations that have a "block" record in
table A
> with an "overlap" of the date range. There are 7 different
possibilities
> for the dates to fall into, 2 of which wouldn't be overlapping the
block
> (the ones where both the start and ends appear before or after the
block).
> How do I detect the rest EASILY?
>
> Thanks!
>
>
[Quoted] there are two ways
arrival_date between start_date and end_date OR departure_date between start_date and end_date
Another:
arrival_date <= end_date and departure_date >= start_date
-- [Quoted] Michael Krolewski Rosetta Inpharmatics mkrolewski_at_rii.com Usual disclaimers Sent via Deja.com http://www.deja.com/Received on Wed Dec 20 2000 - 06:10:11 CET