We are a charity and we have a simple data base to keep track of how many people we help and how much we pay out in food vouchers. I have several reports programmed with date range parameters, i.e. I enter a first date, then a second date, and the report gives me the results. Problem is, on some of these reports, in order to include the actual period I want, I have to add one day to the end date. For example if I want a list of new people who came in during January, if I input the first date as Jan 1 and the end date as Jan 31, the report will not include people who came in on Jan 31. I have to input Feb 1 as the end date. Fair enough, but on other reports, I don’t have to do this, as the results will include the actual end date. Yet the date parameters on the queries read exactly the same.
Example 1: This query provides the value of vouchers paid out between the two dates, and the results always include the end date that I enter.
PARAMETERS [Enter First Date] DateTime, [Enter Last Date] DateTime;
SELECT Visits.Date, Visits.Value, Visits.[Store Voucher], Visits.[Key Contact Number], KeyContact.LastName, KeyContact.FirstName, KeyContact.AutoNumber, Visits.Comments
FROM Visits INNER JOIN KeyContact ON Visits.[Key Contact Number]=KeyContact.AutoNumber
WHERE (((Visits.Date) Between [Enter First Date] And [Enter Last Date]))
ORDER BY Visits.Date;
Example 2: This query provides a list of new people who were helped between the two dates, but for some reason I have to add one day to the end date to get results for that date.
PARAMETERS [Enter First Date] DateTime, [Enter Last Date] DateTime;
SELECT KeyContact.AutoNumber, KeyContact.Category, KeyContact.LastName, KeyContact.FirstName, KeyContact.[Date Added], KeyContact.DOB, KeyContact.Address1
FROM KeyContact
WHERE (((KeyContact.[Date Added]) Between [Enter First Date] And [Enter Last Date]));
Why do these queries behave differently in terms of the end date of the range? It’s driving me crazy. Our original programmer is long gone and I am trying to learn as much as I can about Access. I am using Access 2007, but the db has to be compatible with Access 2002, because we have different versions on different machines.
Example 1: This query provides the value of vouchers paid out between the two dates, and the results always include the end date that I enter.
PARAMETERS [Enter First Date] DateTime, [Enter Last Date] DateTime;
SELECT Visits.Date, Visits.Value, Visits.[Store Voucher], Visits.[Key Contact Number], KeyContact.LastName, KeyContact.FirstName, KeyContact.AutoNumber, Visits.Comments
FROM Visits INNER JOIN KeyContact ON Visits.[Key Contact Number]=KeyContact.AutoNumber
WHERE (((Visits.Date) Between [Enter First Date] And [Enter Last Date]))
ORDER BY Visits.Date;
Example 2: This query provides a list of new people who were helped between the two dates, but for some reason I have to add one day to the end date to get results for that date.
PARAMETERS [Enter First Date] DateTime, [Enter Last Date] DateTime;
SELECT KeyContact.AutoNumber, KeyContact.Category, KeyContact.LastName, KeyContact.FirstName, KeyContact.[Date Added], KeyContact.DOB, KeyContact.Address1
FROM KeyContact
WHERE (((KeyContact.[Date Added]) Between [Enter First Date] And [Enter Last Date]));
Why do these queries behave differently in terms of the end date of the range? It’s driving me crazy. Our original programmer is long gone and I am trying to learn as much as I can about Access. I am using Access 2007, but the db has to be compatible with Access 2002, because we have different versions on different machines.