> return whether that user is signed out between those two
> dates by looking at whether the LeaveDate is between the
> two search dates
Start by creating a few date examples that will cover all
possibilities. Such as
If the search dates are:
Search Start = 11th
Search End = 13th
You want to include these cases
1. Date1 is before Search Start ..AND.. Date2 is between
Search Start and End
Example: 6th to 13th
2. Date1 is between Search Start and End ..AND...Date2 is
after search End
Example: 9th to 17th
3. Date1 is between Search Start and End ..AND...Date2 is
between Search Start and End
Example: 7th to 12th
4. Date1 is before Search Start ...AND...Date2 is after
Search End
Example: 5th to 21st
Next translate those conditions to sql and test with some
sample values. If your fields contain dates only the comparisons
are simple. If they contain a date and time be sure to properly
account for the time in your comparisons.
There are better ways to write this but here is an example of
how you might start translating the 4 conditions above. Once you've
got the initial query working you can improve the sql.
Psuedo-CF/SQL
WHERE ( Date1 < #Start# AND Date2 BETWEEN #Start# AND
#End# )
OR ( Date1 BETWEEN #Start# AND #End# AND Date2 > #End# )
OR ( Date1 BETWEEN #Start# AND #End# AND Date2 BETWEEN
#Start# AND #End# )
OR ( Date1 < #Start# AND Date2 > #End#)