The way I am doing this currently uses a silly amount of loops, there must be a cleaner way.
I have a table of items with their check-out and check-in dates stored as “datetime” fields.
what I am trying to do is query all items that were out at any time between two dates and calculate the number of days they were out within the given date range.
The problem: Finding items which have both the checkout and checkin dates within the range is easy …but there are 3 other conditions to look for:
[LIST][*]
items whose check-out date was prior to the selected date range
items whose check-in date is after the selected date range (or might not even have a checkin date because they are still out)
items whose check-out AND check-in are outside the range.
Any ideas? I have the functions built to calculate the number of days each item was out within the range, but querying the records which have days within the range is the pain.