Re: Availability between dates
- From: "Michel Walsh" <vanderghast@VirusAreFunnierThanSpam>
- Date: Thu, 16 Apr 2009 10:16:09 -0400
The interval [start, end] does not overlap at all the interval [fromThis,
toThis] if, and only if
fromThis > end OR toThis < start
and there is some overlap (partial or total) with the negation of the
previous statement, or if you prefer, if:
fromThis <= end AND toThis >= start
(using the so called De Morgan's law)
So, a possible solution is to check all items with a possible overlap, then,
make a second query which will look at all the items not in the first set.
The first query is thus:
SELECT itemID
FROM table2
WHERE hireoutFrom <= [periodEnd] AND hireoutUntil >= [periodStart]
which returns items 'hired' within (some part of) the period
[periodStart], [periodEnd] . Assume you save this query as q1. The second
and final query is:
SELECT itemID
FROM table1 LEFT JOIN q1
ON table1.itemID = q1.itemID
WHERE category = [wantedCategory]
AND q1.itemID IS NULL
would return the items not hired for any part of the said period, said
[wantedCategory].
Vanderghast, Access MVP
"Eddie Holder" <eddiesanet@xxxxxxxxxxx> wrote in message
news:C550B019-858C-44F6-9F68-7081CE1A5641@xxxxxxxxxxxxxxxx
Hi Guys - I hope someone can help. I have a database that hires out
products,
and need help to try and find which products are available for hire
between
date A and data b. Here it goes
I have a database with 2 tables.
Table 1 - this holds product information with each product having a unique
ID and belonging to a category, e.g. seats, chairs, tables, etc
Table 2 - This holds all the hired out products and the date from and the
date to when it's hired out, e.g. Product 1, in seats category is hired
out
from the 01/01/09 to the 15/01/09
When I have a request for a new hire, I would like to be able to run a
query
that will return which products can be hired based on the hire request
date
from and request date to, e.g. I would like to hire a seat from the
10/01/09
to the 13/01/09.
As we will have multiple products in each category, I would like to search
by category to find which products are available. e.g. show me all seat
products that can be hired on the hire request date.
Any advice or help will be appreciated.
Thank you in advanced!
Eddie
.
- Follow-Ups:
- Re: Availability between dates
- From: Eddie Holder
- Re: Availability between dates
- References:
- Availability between dates
- From: Eddie Holder
- Availability between dates
- Prev by Date: Really need help with a query
- Next by Date: RE: Really need help with a query
- Previous by thread: Availability between dates
- Next by thread: Re: Availability between dates
- Index(es):
Relevant Pages
|