Selecting between dates

  • Thread starter Thread starter cheswyck
  • Start date Start date
C

cheswyck

I have a log file with a date created using now(). I want
to select log records that fit within two dates passed to
it by another form. the log date is date and time. How
do I select the record if the log date&time is between the
date range given? I tried using 'Between startDate and
EndDate' but that didn't work. Do I have to seperate the
date in the logDate field?
 
By using Now() to create the values in the field, you're storing both date
and time. If all you want is the date, then use Date() function instead of
Now() function.

The reason you're having a problem with your query is that a date (no time)
is a nondecimal number that corresponds to midnight of that date. With a
time, the value is the date value plus a fractional portion that represents
the time as a fraction of a 24-hour day. Thus, because your field has time
in it too, you must extend the upper limit (EndDate) by 1 so that it obtains
all values with the date of EndDate regardless of the time value.
Between startDate And (EndDate + 1)

This should give you your desired results from your data.
 
Back
Top