showing available dates to book a room

TheSmiddy

New Member
Joined
Jul 16, 2004
Messages
4
so far i have set up a query which asks the user for a starting date and an ending date and then displays all the rooms that are booked inbetween those dates.

i then wanted another query to run off the first query which displays all the rooms that didnt show up in the first query. this query doesnt work no matter what i try.

Does anybody know what i can do or are there any suggestions for an alternative method of incorporating a feature like this?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
What do you mean by did not show up?

Are you trying to get the rooms that were not booked?

Can you post the SQL?

To do so goto query design then View>SQL View and copy what is there.
 
Upvote 0
yeah i was trying to get the rooms that are not booked in between two user selected dates

query for booked dated (working)

PARAMETERS [Please enter commencement date] DateTime, [Please enter ending date] DateTime;
SELECT rentals.PropertyID, rentals.[commencement date], rentals.[ending date]
FROM rentals
WHERE (((rentals.[commencement date]) Between [Please enter commencement date] And [Please enter ending date]-1)) OR (((rentals.[ending date]) Between [Please enter commencement date] And [Please enter ending date])) OR (((rentals.[commencement date])<[Please enter commencement date]) AND ((rentals.[ending date])>[Please enter ending date]-1));

query for available dates

SELECT [booked dates].PropertyID
FROM [booked dates]
WHERE ((([booked dates].PropertyID) Is Null));
 
Upvote 0
Try this in a new query

PARAMETERS [Please enter commencement date] DateTime, [Please enter ending date] DateTime;
SELECT rentals.PropertyID, rentals.[commencement date], rentals.[ending date]
FROM rentals
WHERE (((rentals.[commencement date]) Not Between [Please enter commencement date] And [Please enter ending date]-1)) AND (((rentals.[ending date])Not Between [Please enter commencement date] And [Please enter ending date])) AND (((rentals.[commencement date])>=[Please enter commencement date]) OR ((rentals.[ending date])<=[Please enter ending date]-1));

Basically reversing your previous query
 
Upvote 0
thanks, does this mean i can delete the booked dates query or is that still needed?

oh also, if a room has never been booked before it wont appear in the query, do i have to create a "fake" booking (ie book it from 1/1/1901 to 2/1/1901) or is there a way around it
 
Upvote 0
If what I gave you works you can delete it I suppose.

But make sure that mine does work.
 
Upvote 0

Forum statistics

Threads
1,221,780
Messages
6,161,888
Members
451,730
Latest member
BudgetGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top