Think about this: when you enter 8/31/08, what time is represented by that
string? Keep in mind that the string has to be converted to a date/time
value, which ALWAYS has a time component.
Are you seeing the problem yet? What time is represented by .0?
The answer is midnight ... 00:00:00.
Now you say you have three records for 8/31/08 ... I suspect the times
stored in those values are greater than midnight, are they not? so, they
will all be greater than the date/time value obtained by converting
"8/31/08" to date/time.
The solution?
One school of thought says to eschew BETWEEN in this situation, using
datetimefield >= #8/1/08# and datetimefield < #9/1/08#
instead. To make that work with parameters, assuming the user will enter
8/31 for the end date, add 1 day to the End Date parameter:
datetimefield >= [Start Date] and datetimefield < DateAdd("d",1,[End Date])
Another suggests that since none of the values in the table contain
midnight, then using
datetimefield BETWEEN [Start Date] AND DateAdd("d",1,[End Date])
is just as effective.
If some of the values in the table DO contain midnight, then add just a
little less to the end date
datetimefield BETWEEN [Start Date] AND DateAdd("s",86399,[End Date])
Take your pick.
Lord, yes I have 3 record with that date. If I enter 9/1/08 as end
date then it shows data from 8/31/08 as well. Entering the paramater
as you suggested works fine but I intend to enter the sql statement
directly in my repot. It appears to me that the end date is excluded
from the valid range.
Lord Kelvan said:
are you sure there is actually data on the 31st
if so you coudl try defining the paramaters
open your query in design view and then click query in the menu bar
then click paramaters then in there type [Start date] and set the
data type to date/time and on an new line type [end Date] and set it
to date/time