Access Database Help

Associate
Joined
19 Mar 2005
Posts
569
Currently making an access hotel booking system and am abit stuck, need to produce a report of the people checking out within 2 days

I have used

Code:
DateAdd("d",2,Date())

Which picks up check outs 2days in advance but I cant quite figure out how to do within 2days :confused:.

Just wondering how I would do this?

Edit.
have tried put <= but this returns results of past bookings, how can i get it to only display checkouts from today onwards till 2 days have gone?

Edit.

Do I need to compare the value to the date()?

Anyone please?
 
Last edited:
Soldato
Joined
18 Oct 2002
Posts
3,896
Location
Cheshire
Well if DateDiff("d", arrivalDate, date()) was greater than or equal to 0 (or just greater than if you don't want people arriving today) then the customer would have arrived... if DateDiff("d", checkoutDate, date()) was less than or equal to 0 (or just less than if you don't want people checking out today) then the customer hasn't left yet.. combine the two with an AND and you should have people that are currently there.

Had a few drinks, but hopefully that's right :p
 
Associate
OP
Joined
19 Mar 2005
Posts
569
Cheers Beepcake

Is it something like the code below which I cant get to work

Code:
SELECT Customer.CustomerID, Customer.FirstName, Customer.Surname, Rooms.RoomNum, Rooms.RoomType, Booking.Arrival, Booking.Checkout
FROM Rooms INNER JOIN (Customer INNER JOIN Booking ON Customer.CustomerID = Booking.CustomerID) ON Rooms.RoomNum = Booking.Room
WHERE (DateDiff("d",Booking.Arrival,Date())>0 And DateDiff("d",Booking.Checkout,Date()) < 0);
 
Last edited:
Associate
OP
Joined
19 Mar 2005
Posts
569
Solved it in the end with

Code:
SELECT Customer.CustomerID, Customer.FirstName, Customer.Surname, Rooms.RoomNum, Rooms.RoomType, Booking.Arrival, Booking.Checkout
FROM Rooms INNER JOIN (Customer INNER JOIN Booking ON Customer.CustomerID = Booking.CustomerID) ON Rooms.RoomNum = Booking.Room
WHERE (((DateDiff("d",[Arrival],Date()))>0) AND ((DateDiff("d",[Checkout],Date()))<0));

Damn Square Brackets needed for field names in where clause.
 
Back
Top Bottom