Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / November 2006

Tip: Looking for answers? Try searching our database.

dates between

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bibi - 29 Nov 2006 00:28 GMT
I have a rental database - There are three primary tables.  Properties,
Leases and Tenants. The Leases table has two date fields - Arrive and Depart
-There are multiple properties that may be leased.   I need to be able to
identify which dates are available for lease and which are reserved for each
property.  The Arrive Date is leased, the depart date is not leased and there
may be any number of dates in between which are leased. As a stop gap measure
I have created a table and manually enter each date as Reserved when a lease
is signed, but even this does not show me at a glance which dates are
AVAILABLE for which properties and that's what I need to be able to see at a
glance.  Any suggestions?
TIA
Bibi
Allen Browne - 29 Nov 2006 01:34 GMT
You want to select the properties that are not leased. Those are the ones
that have no record where today is between the Arrive and Depart dates.

SELECT Properties.*
FROM Properties
WHERE NOT EXISTS
 (SELECT Leases.LeaseID
 FROM Leases
 WHERE (Leases.PropertyID = Properties.PropertiesID)
   AND (Date() >= Leases.Arrive)
   AND (Date() < Leases.Depart));

If subqueries are new, see:
   How to Create and Use Subqueries
at:
   http://support.microsoft.com/?id=209066

An alternative approach would be to:
1. Create a query based on the Leases table.
2. Drag PropertyID into the grid.

3. In a fresh column of the Field row, enter:
       Date()

4. In the Criteria row beneath this:
   Between [Arrive] And ([Depart] - 1)

5. Save the query.

6. Use the Unmatched query wizard (first dialog when you create a new query)
to make a query selecting the properties from the Properties table that are
not in that query.

Signature

Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I have a rental database - There are three primary tables.  Properties,
> Leases and Tenants. The Leases table has two date fields - Arrive and
[quoted text clipped - 14 lines]
> TIA
> Bibi
Jamie Collins - 29 Nov 2006 10:16 GMT
> > I have created a table and manually enter each date as Reserved when a
> > lease
> > is signed, but even this does not show me at a glance which dates are
> > AVAILABLE for which properties and that's what I need to be able to see at
> > a
> > glance.  Any suggestions?

Use a Calendar auxiliary table:

http://www.aspfaq.com/show.asp?id=2519

Jamie.

--
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.