Query/SP to determine if date range overlaps record date ranges
Posted on 2006-06-30
I'm looking for a SELECT statement or stored procedure that allows me to return records whose date range overlaps a specified date range. Here is a sample table:
cid course_name date_start date_end description
1 Intro to Stuff 5/30/2006 7/2/2006 null
2 Ethics 1/2/2006 1/31/2006 null
3 Physics I 2/20/2006 7/1/2006 null
4 Adv. Algebra 2/23/2006 4/23/2006 null
5 Accounting 101 1/27/2006 6/6/2006 null
Let's say I give the user the following input:
Date Start: ____________
Date End: ____________
Let's say the user enters a start date of 1/25/2006 and an end date of 2/22/2006. I want to return all records that have dates have start/end dates that overlap the user input, 1/25/2006-2/22/2006, which in this example would be records 2, 3, and 5.
Does anyone understand what I'm looking for? Can you come up with a solution?