Hi, I’m trying to set up a query to find all dates on or between a start and end date.
Table name and field names I’ve used:
Tbl_bookings
Booking No
Boarding Arrival Date
Boarding Departure Date
So far I’ve been using the criteria:
>=[Enter the arrival date]And<=[Enter the departure date]
under the arrival date field.
The SQL for the query is as follows:
[CODE=SQL]SELECT tbl_bookings.[Booking No], tbl_bookings.[Boarding Arrival Date], tbl_bookings.[Boarding Departure Date]
FROM tbl_bookings
WHERE (((tbl_bookings .[Boarding Arrival Date])>=[Enter Arrival Date] And (tbl_bookings.[Boarding Arrival Date])<=[Enter Departure Date]));[/CODE]
The problem that I’m having is when I enter a set of two dates and the departure date is greater than the departure date stored in the bookings table.
For example the test data I’m currently using is as follows:
Test Data
I enter the dates 01/01/2008 to 07/01/2008 in the parameter value boxes and bookings 2,5,6,7 are returned as expected.
However if I enter 06/01/2008 to13/01/2008 only bookings 5,6,7 are returned yet booking 2 should also have been
I have the same problem again entering values such as 10/01/2008 to 11/02/2008, bookings 9,10 are returned but not 5,6,7.
I quite new to using access and was wondering if someone could point me in the right direction as to how to develop this query so that it works for when the departure date entered is not less than or equal to dates that are stored in the system.
Many Thanks
Table name and field names I’ve used:
Tbl_bookings
Booking No
Boarding Arrival Date
Boarding Departure Date
So far I’ve been using the criteria:
>=[Enter the arrival date]And<=[Enter the departure date]
under the arrival date field.
The SQL for the query is as follows:
[CODE=SQL]SELECT tbl_bookings.[Booking No], tbl_bookings.[Boarding Arrival Date], tbl_bookings.[Boarding Departure Date]
FROM tbl_bookings
WHERE (((tbl_bookings .[Boarding Arrival Date])>=[Enter Arrival Date] And (tbl_bookings.[Boarding Arrival Date])<=[Enter Departure Date]));[/CODE]
The problem that I’m having is when I enter a set of two dates and the departure date is greater than the departure date stored in the bookings table.
For example the test data I’m currently using is as follows:
Test Data
Code:
Booking No Arrives Departs
2 01/01/2008 08/01/2008
5 07/01/2008 12/01/2008
6 07/01/2008 12/01/2008
7 07/01/2008 12/01/2008
9 09/02/2008 14/02/2008
10 09/02/2008 14/02/2008
However if I enter 06/01/2008 to13/01/2008 only bookings 5,6,7 are returned yet booking 2 should also have been
I have the same problem again entering values such as 10/01/2008 to 11/02/2008, bookings 9,10 are returned but not 5,6,7.
I quite new to using access and was wondering if someone could point me in the right direction as to how to develop this query so that it works for when the departure date entered is not less than or equal to dates that are stored in the system.
Many Thanks
Comment