Access is messing up my query sql

P

Pachydermitis

Help, What am I missing?
I have a query that I am limiting by date - between 4/2002 and 9/2004.
Unfortunately , I only have months and years to work with.
When I make the where statement:
(Month([Date])>=4 And Year([Date])>=2002) And (Month([Date])<=9 And
Year([Date])<=2004)
Access kindly changes it to:
((Month([Date]))>=4 And (Month([Date]))<=9) AND ((Year([Date]))>=2002
And (Year([Date]))<=2004))
Which is not remotely the same thing.
Thanks in advance
Pachydermitis
 
B

Brian Camire

Yes it is.

In general

(A And B) And (C And D)

is equivalent to

(A And C) And (B And D)

is equivalent to

A And B And C And D

Both criteria will (incorrectly) exclude cases like 1/2003.

You might instead try something like:

[Date]>=DateSerial(2002,4,1) And [Date]<DateSerial(2004,9+1,1)
 
Top