I have two variables containing dates. DateStart and DateEnd (in SQL).
I also have two DatePicker controls (in a WinForm).
I import the two dates from the database and need to do something tricky.
So the two variables create a range of dates and the two date pickers create another range of date.
How can I check if these dates range are overlapping with a Sql query ?
E.g (yyyy/mm/dd format)
DateStart = 2012/07/01, DateEnd = 2012/07/31
| DatePicker1 | DatePicker2 | Overlapping |
--------------------------------------------
| 2012/07/15 | 2012/07/16 | True |
--------------------------------------------
| 2012/07/31 | 2012/08/01 | True |
--------------------------------------------
| 2012/06/20 | 2012/07/01 | True |
--------------------------------------------
| 2012/08/01 | 2012/09/01 | False |
--------------------------------------------
I know it’s a little messed up but I didn’t know how else to ask this.
Two date ranges overlap if start of first range is before end of second range and end of first range is after start of second range. So:
A good explanation is this way.