PDA

View Full Version : ASP/MSAccess Query: Where I am Wrong?



webmulgor
February 21st, 2007, 08:45 AM
:h:

strSQL = "SELECT matri.* FROM matri WHERE matri.d_dob between # '"& dobto &"' # and #'" & dobfrom &"'#;"

dobto and dobfrom is storing two different dates.
d_dob is Date Field

Error i get is...
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression 'matri.d_dob between # '2/23/1973' # and #'2/23/1982'#'.

borrob
February 21st, 2007, 10:42 AM
between # '2/23/1973' # and #'2/23/1982'#'.
i'm not such a freak in microsoft odbc but still i think the qoutes are wrong it should be:
between '# 2/23/1973#' and '#2/23/1982#'

webmulgor
February 22nd, 2007, 01:41 AM
GOT IT----------You are right .[i have removed the quotes and added & sign..]. quotes were creating the error..

Following is working nicely.

"SELECT matri.* FROM matri WHERE matri.d_dob between # "& dobto &" # and #" & dobfrom &"#;"