WHERE (((r.date_time) '9/1/02' and '9/15/02 23:59:29'
and datepart(hh,date) between 7 and 23
) AND ((r.ct_id)=1))
GROUP BY LTrim(Str(DatePart("m",r.date_time)))+IIf(DatePart("d",r.date_time)<10,"/0","/"+LTrim(Str(DatePart("d",r.date_time)))+"/"+LTrim(Str(DatePart("yyyy",r.date_time)))
HAVING (((Int(Sum([r].[in_time]+[r].[acw_time])/100))<>0))
ORDER BY LTrim(Str(DatePart("m",r.date_time)))+IIf(DatePart("d",r.date_time)<10,"/0","/"+LTrim(Str(DatePart("d",r.date_time)))+"/"+LTrim(Str(DatePart("yyyy",r.date_time)));
Instead of these inefficient dateparts, take advantage of the fact that dates in Access are stored in terms of days from 1/1/1900.
WHERE
r.date_time >= #9/1/2002# AND
r.date_time < #9/16/2002# AND
fpart(r.date_time)
Between #1/1/1900 07:00:00# And #1/1/1900 23:00:00#
The first part does the date, the second part does the time. Note that fpart is VBA, not Jet SQL, so the engine cannot optimize for it. The Jet SQL engine runs the first criteria, returns the result to Access, and Access applies the second criteria.
This is still better than the dateparts, since datepart is VBA. The Jet SQL engine returns the entire table, and Access applies the datepart criteria. This is extremely slow because Access has do all of the processing. Jet SQL processing is always faster than Access.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.