I have a start order date field and a stop order field I need to check the database to see if the start and stop orders are outside of any of the pay period start and end fields. Say 01-aug-10 and 14-aug-10 and 15-aug-10 and 28-aug-10 and 29-aug-10 and 11-sep-10 are all of the pay periods in one month. The start order 01-aug-10 and the end order is 14-aug-10. Yet when I do a SQL that said (where end order not between pay period start and pay period end) the 01-aug-10 to 14-aug-10 still shows up. My needs are if it finds any dates that match stop looking and go to the next record start order and stop order and start the next search till we hit the end of the record search requirements.
I am looking to search by month and by year to keep the query responsive. The database is quite large. My query seams like it only does the between check once and then it shows all of the data that does fit between the pay period start and stop, and that is the data I do not want to see!