469,312 Members | 2,464 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

SQL question

can anyone tell me what's wrong with this?

searchSQL = "Select * FROM Events WHERE Date >=#" & DateBegin & "# AND Date
<=#" & DateEnd & "# ORDER BY Date " & sort & ";"

I have a form sending the correct data but I can't get this to recognize the
'Date<=' For example, when I do a search and a date lands on the last day
of the month, it doesn't turn up. It reports the 'greater than or equal to'
but not the later. What am I doing wrong?

I'm not a SQL pro so don't kill me...

Thanks!!!
John
Jul 19 '05 #1
3 1618
do a response.write on the SQL once and see what it shows..
Also...is this MS Access?
--
----------------------------------------------------------
Curt Christianson (Software_AT_Darkfalz.Com)
Owner/Lead Designer, DF-Software
http://www.Darkfalz.com
---------------------------------------------------------
...Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"John K" <no***@amIgivingitouthere.com> wrote in message
news:hM*********************@twister.nyroc.rr.com. ..
can anyone tell me what's wrong with this?

searchSQL = "Select * FROM Events WHERE Date >=#" & DateBegin & "# AND Date <=#" & DateEnd & "# ORDER BY Date " & sort & ";"

I have a form sending the correct data but I can't get this to recognize the 'Date<=' For example, when I do a search and a date lands on the last day
of the month, it doesn't turn up. It reports the 'greater than or equal to' but not the later. What am I doing wrong?

I'm not a SQL pro so don't kill me...

Thanks!!!
John

Jul 19 '05 #2
grw
Also posted in asp.db

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:u1**************@tk2msftngp13.phx.gbl...
do a response.write on the SQL once and see what it shows..
Also...is this MS Access?
--
----------------------------------------------------------
Curt Christianson (Software_AT_Darkfalz.Com)
Owner/Lead Designer, DF-Software
http://www.Darkfalz.com
---------------------------------------------------------
..Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"John K" <no***@amIgivingitouthere.com> wrote in message
news:hM*********************@twister.nyroc.rr.com. ..
can anyone tell me what's wrong with this?

searchSQL = "Select * FROM Events WHERE Date >=#" & DateBegin & "# AND

Date
<=#" & DateEnd & "# ORDER BY Date " & sort & ";"

I have a form sending the correct data but I can't get this to recognize

the
'Date<=' For example, when I do a search and a date lands on the last day of the month, it doesn't turn up. It reports the 'greater than or equal

to'
but not the later. What am I doing wrong?

I'm not a SQL pro so don't kill me...

Thanks!!!
John


Jul 19 '05 #3
I know, I should have caught that sooner. This was actually a 3rd party app
I found at aspin. Used it to save time, didn't have enough to write one
from scratch. I've been tweakin it and problems like this keep coming up,
arg. It also came with the Date field including the Time which is a pain
because I'll have to go back and create a new field for time and rewrite all
the sql calls because it screws up searches, e.g. BETWEEN #DATE# AND #DATE#
if the time is greater than midnight....pain in the kee. So much for saving
time....
"Phill. W" <P.******@open.ac.uk> wrote in message
news:bh**********@yarrow.open.ac.uk...
"John K" <no***@amIgivingitouthere.com> wrote in message
news:hM*********************@twister.nyroc.rr.com. ..
can anyone tell me what's wrong with this?

searchSQL = "Select * FROM Events WHERE Date >=#" & DateBegin & "# AND

Date
<=#" & DateEnd & "# ORDER BY Date " & sort & ";"


John,

1). Don't use "Select *", it's downright inefficient,
2). Don't use "Date" as a column name; it's a reserved word
3). Investigate the SQL keyword "Between",
4). Make sure the dates you supply "make sense" to your database,
by which I mean /format/ your dates before adding them into the
SQL. Wherever I can, I use this format - "yyyy-mm-dd hh:nn:ss"
- just about everything can understand it without any ambiguity.

HTH,
Phill W.

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mohammed Mazid | last post: by
3 posts views Thread by Stevey | last post: by
10 posts views Thread by glenn | last post: by
53 posts views Thread by Jeff | last post: by
56 posts views Thread by spibou | last post: by
2 posts views Thread by Allan Ebdrup | last post: by
3 posts views Thread by Zhang Weiwu | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.