When defining a date range by means of a BETWEEN….AND operation, any rows
containing date/time values on the last day of the range where the time of
day element is greater than zero will not be returned (for the reason the
other respondents have explained). Its very easy for dates to be given a
non-zero time of day inadvertently unless you take steps in the table
definition to prevent this; the use of the Now() function to insert a value
is a common culprit.
You can easily return rows which included dates on the final day of the
range even if the values include a non-zero time of day by defining the range
as follows:
SELECT *
FROM [YourTable]
WHERE [YourDateField] >= DATE()-1
AND [YourDateField] < DATE()+1;
If a date/time value is on or after midnight at the start of yesterday, and
before midnight at the start of tomorrow then the WHERE clause will evaluate
to TRUE and the row will be returned. Midnight is treated by Access as 'zero
hour', i.e. the very first 'moment' of the day, though it might also be
regarded as the very last 'moment' of the day. Joe Celko briefly discusses
this point in connection with the ISO date/time standard (which allows both
notations, 00:00 and 24:00 for midnight) in his book 'Data and Databases –
Concepts in Practice'. If you are interested in the ISO standard take a look
at:
http://www.cl.cam.ac.uk/~mgk25/iso-time.html
Ken Sheridan
Stafford, England