Selecting in between dates

  • Thread starter Thread starter me
  • Start date Start date
M

me

How do you do selection in between dates in a query? For example,
qryBetweenDates would be from Mar 20, 2004 thru Mar 27, 2004. This comes
from a table of Events where the dates are located at and Individuals where
the People names are.

TIA
 
In the criteria for the date field, have something like this:

BETWEEN #3/20/2004# AND #3/27/2004#

But be careful! This will only work prperly if the date field contains
"pure" dates, with no time part. That is what you get from the Date ()
built-in Function. Many people use Now () to insert the current date
_and_ _time_ into a date field, even when they really only want the
current date. If you do this, the above criterion, which selects only
date/times between 00:00 hours on 3/20/2004 and _00:00_ _hours_ on
3/27/2004, will only include records from the last date for which the
time part is zero - in the circumstances outlined, there are likely to
be rather few of these!

The safest approach is to apply the selection criteria to a calculated
column defined as DateValue (dtYourField) - the DateValue Function
will strip any time part off a date/time value and return only the
date part.

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Back
Top