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

SQL code not returning correct data

P: n/a
Hello,

I have an access sql code with dates between #10/25/2005# and
#11/04/2005#. In addition, I have an "OR". I am getting records past
11/04/2005. How can I structure the code to eliminate records past
11/04/2005? Here is my code:

SELECT tblAllSurvey.Inst1_ID, tblAllSurvey.Inst2_ID,
tblAllSurvey.Inst3_ID, Left([SessionDate],10) AS ss, tblAllSurvey.Q21
FROM tblAllSurvey
WHERE (((tblAllSurvey.Inst1_ID)=40) AND ((Left([SessionDate],10))
Between #10/21/2005# And #11/4/2005#) AND ((tblAllSurvey.Q21) Is Not
Null)) OR (((tblAllSurvey.Inst2_ID)=40) AND ((Left([SessionDate],10))
Between #10/21/2005# And #11/4/2005#) AND ((tblAllSurvey.Q21) Is Not
Null));

Thanks in advance for your help.

Edgar

Dec 1 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Edgar wrote:
Hello,

I have an access sql code with dates between #10/25/2005# and
#11/04/2005#. In addition, I have an "OR". I am getting records past
11/04/2005. How can I structure the code to eliminate records past
11/04/2005? Here is my code:

SELECT tblAllSurvey.Inst1_ID, tblAllSurvey.Inst2_ID,
tblAllSurvey.Inst3_ID, Left([SessionDate],10) AS ss, tblAllSurvey.Q21
FROM tblAllSurvey
WHERE (((tblAllSurvey.Inst1_ID)=40) AND ((Left([SessionDate],10))
Between #10/21/2005# And #11/4/2005#) AND ((tblAllSurvey.Q21) Is Not
Null)) OR (((tblAllSurvey.Inst2_ID)=40) AND ((Left([SessionDate],10))
Between #10/21/2005# And #11/4/2005#) AND ((tblAllSurvey.Q21) Is Not
Null));

Thanks in advance for your help.

Edgar

Don't compare a date to a string would be my first response. If
SessionDate is a string, see CDate in help.
Dec 1 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.