Reputation: 8384
I got a mysql table with columns from_date
and to_date
.
I also got a second timespan in PHP consisting of $monday
and $friday
.
Now I want to select all entries from my table which's timespan includes atleast one day inbetween $monday
and $friday
.
I first thought about something like this:
WHERE `from_date` >= :monday
AND `to_date` <= :friday
But this would not include entries where from_date
is smaller then :monday
or to_date
is greater then :friday
Upvotes: 0
Views: 395
Reputation: 125865
I think you want to select records which start before the end of your range and end after the start of it:
WHERE from_date <= :friday AND to_date >= :monday
Upvotes: 2