By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,139 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,139 IT Pros & Developers. It's quick & easy.

Problem using an interlocked WHERE-Clause

P: n/a
Hi everybody,

I have a problem with my SQL-Statement:

SELECT *
FROM [Excel Export Query]
WHERE (((Year > 2003) And (Month <= 6)) Or (Year = 2003))

The WHERE-clause doesn't work properly. As result I receive all
entries from 2003 and 2004 where the month is <= 6.
But I need to get all entries from 2003 (month 1-12) and the entries
from 2004 (month 1-6).

Does anybody know, why this interlocked statement doesn't work?

THANK YOU SO MUCH!

Best wishes,
Stephan
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Stephan
Try
WHERE (((Year([YourDateField]) > 2003) And (Month([YourDateField]) <= 6)) Or
(Year([YourDateField) = 2003))

Stewart

"kuhni" <st************@gmx.de> wrote in message
news:88**************************@posting.google.c om...
Hi everybody,

I have a problem with my SQL-Statement:

SELECT *
FROM [Excel Export Query]
WHERE (((Year > 2003) And (Month <= 6)) Or (Year = 2003))

The WHERE-clause doesn't work properly. As result I receive all
entries from 2003 and 2004 where the month is <= 6.
But I need to get all entries from 2003 (month 1-12) and the entries
from 2004 (month 1-6).

Does anybody know, why this interlocked statement doesn't work?

THANK YOU SO MUCH!

Best wishes,
Stephan

Nov 13 '05 #2

P: n/a

"kuhni" <st************@gmx.de> wrote in message
news:88**************************@posting.google.c om...
Hi everybody,

I have a problem with my SQL-Statement:

SELECT *
FROM [Excel Export Query]
WHERE (((Year > 2003) And (Month <= 6)) Or (Year = 2003))

The WHERE-clause doesn't work properly. As result I receive all
entries from 2003 and 2004 where the month is <= 6.
But I need to get all entries from 2003 (month 1-12) and the entries
from 2004 (month 1-6).

Does anybody know, why this interlocked statement doesn't work?


SELECT *
FROM [Excel Export Query]
WHERE
([Year] = 2003)
OR
([Year] = 2004 AND [Month] <= 6)
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.