Apologies on the question title I’m having a hard time articulating this. It’s much easier via example:
I have a table with two date fields; start_date and end_date. Dummy data:
+----+------------+------------+
| id | start_date | end_date |
+----+------------+------------+
| 1 | 2012-01-10 | 2012-04-13 |
| 2 | 2012-02-09 | 2012-05-12 |
| 3 | 2012-03-08 | 2012-06-11 |
| 4 | 2012-04-07 | 2012-07-10 |
| 5 | 2012-05-06 | 2012-08-09 |
+----+------------+------------+
So now I have a given month, let’s say March 2012. Is there a way to see if March 2012 falls within start_date and end_date for id 2? How about 3 (3 is a bit different as parts of March 2012 fall between start_date and end_date which is fine, we don’t need the whole month, parts are fine)?
I’ve been sitting here trying to think of how to write a query and am completely stumped
If you can use the exact month range (i.e. give exact day of start end day) then such query should work fine: