Access is messing up my query sql

  • Thread starter Thread starter Pachydermitis
  • Start date Start date
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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top