Fix for #1311

Logic of date filters had been mixed-up
The logic is confusing in that you compare the start date to the end of the range, and the end date to the start of the range. But that is how you get the correct behaviour.