Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 select overlaps between two date ranges

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-31 : 07:55:26
Steve writes "What's the easiest/best way to match items by date ranges, not individual dates.

I have two tables of events. For each event in each table is recorded a start date and an end date. What I want to do is return the list of events in one table that overlap with a specified event in the second.

Eg if the specified event runs all March, I want the list of events in the first table that run completely within March, that start in Feb and run into March, or start in March and run into April.

Each attempt I made ended up with lots of "a < b < c" like statements; must be an easier way (I thought using Sets? - each event has a "set of dates" that we compare? does SQL do sets?).

This is for SQL 7 (SP2) under NT 4 (SP5), via ASP.

Thanks.

Steve"
   

- Advertisement -