SQL Select rows with date within another date range

CREATE TABLE TestTable(   ID           INT PRIMARY KEY,   StartDate    SMALLDATETIME,   EndDate      SMALLDATETIME);insert into TestTable(ID,StartDate,EndDate) values (1,'2000-11-11 10:11:11', '2000-11-11 13:11:11');insert into TestTable(ID,StartDate,EndDate) values (2,'2000-11-11 10:22:22', '2000-11-11 14:11:11');insert into TestTable(ID,StartDate,EndDate) values (3,'2000-11-11 10:32:22', '2000-11-11 14:11:11');insert into TestTable(ID,StartDate,EndDate) values (4,'2000-11-11 11:01:11', '2000-11-11 15:11:11');insert into TestTable(ID,StartDate,EndDate) values (5,'2011-02-02 22:22:22', '2011-02-22 22:22:22');insert into TestTable(ID,StartDate,EndDate) values (6,'2000-11-11 11:32:22', '2000-11-11 14:11:11');SELECT * FROM TestTable

Leave a Reply

Your email address will not be published. Required fields are marked *