One nitpick. Your criteria won't return any records on 12/31/2005 since
the
time_open is after midnight on that date. All that requires is one slight
change to your criteria. Change 12/31/2005 to 1/1/2006. This will get
all
records up to 23:59:59 on December 31, 2005 and the time value will then
screen
that down to only records within the time period.
SELECT Incident.*
FROM Incident
WHERE (((Incident.time_open)>=#7/1/2005# And
(Incident.time_open)<#1/1/2006#) AND
((TimeValue([time_open]))>=#12/30/1899
8:0:0# And (TimeValue([time_open]))<#12/30/1899 9:0:1#));
Thanks to All for the quick reply!! I was able to use Rick & Marshall's
suggestion and ended up with the following statment:
SELECT Incident.*
FROM Incident
WHERE (((Incident.time_open)>=#7/1/2005# And
(Incident.time_open)<#12/31/2005#) AND
((TimeValue([time_open]))>=#12/30/1899
8:0:0# And (TimeValue([time_open]))<#12/30/1899 9:0:1#));
Works like a charm!!
Thansk again to all!!
:
Bill wrote:
Hi All,
I need to run a query that finds all the records between 7/1/05 and
12/30/05 and only the records between 8:00am and 9:00am. I have the
date range part but I can not figure out the time range part.
Any help would be appreciated Thanks!! Bill
No idexed ay of doing this that I know of. Best I can think of is...
SELECT...
FROM TableName
WHERE DateField >= #2005-07-01#
AND DateField < #2005-12-31#
AND TimeValue(DateField) >= #8:00:00#
AND TimeValue(DateField) < #9:00:01#
The above should be able to use an index for the date criteria, but
will have to
scan those rows for the Time criteria.
Since "between 8 and 9 am" is subject to different interpretation I
guessed on
what you meant by that. The above would include a record whose time
was exactly
9:00:00 am but filter out anything later than that.