So im gonna try to explain this:
I got datepicker where you select 2 dates (start and end).
For example:
01-01-2012 till 11-12-2012
Now im gonna use these dates to search for jobs in a table:
startdate job: 10-10-2012
enddate job: 20-12-2012
I want to get that job as a result, because the job is running between those 2 dates.
I tried to use BETWEEN but that doesn’t seem to work for me. Can somebody help me with the query? Ofcourse i translate the date format to yyyy-mm-dd.
The point is that i want to show the job even if only 1 day is in the range of the datepicker date.
You’re looking for the intersection of 2 date ranges. So given dateranges d1 and d2, you know that d2.start must occur before d1.end. You also know that d2.end must occur after d1.start. If both conditions are true, then you have overlap. In SQL:
ETA diagram for clarity: