ASP / Incorrect syntax near '#' in Between SQL statement


ASP ---> I keep getting an error page message. The code doesn't seem to parse or the syntax is incorrect.  Do you know what may be wrong in "Between" statement.  It connects to a SQL Sever DB and I know it checks the tags first ... I don't thinks that I miss place one.  

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '#'.

  strSQL="Select * From SQLTbl "
   strSQL=strSQL & " Where [call date] between "
   strSQL=strSQL & "#" & varGetStartDate & "# and #" & varGetEndDate & "#"
   Response.Write "<HR>" & strSQL & "<HR>"
   rs.Open strSQL, conn, adOpenStatic

Who is Participating?
Jim HornConnect With a Mentor Microsoft SQL Server Developer, Architect, and AuthorCommented:
SQL Server uses ' to delineate dates.  Access uses pound signs #.  

Try this...
strSQL="Select * From SQLTbl "
strSQL=strSQL & " Where [call date] between "
strSQL=strSQL & "'" & varGetStartDate & "' and '" & varGetEndDate & "'"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.