Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date variable in select gives error 1

Status
Not open for further replies.

thunderain

Programmer
Jan 10, 2002
40
CA
This should be a simple fix. This is the select clause i am using with microsoft access database using date variable. It works perfect. Date variable is occValue.


strSQL = objRS1("SelectClause") & " AND (" & fieldname & " Like #" & occValue & "#) ORDER BY " & fieldname

I need to use this in sql server. It seems to have a problem reading the date varible with this:
#" & occValue & "#.

For example with the date variable 4/25/2002 11:05:06 AM coming in from the previous page form, it gives the error:

Line 1: Incorrect syntax near '11'.


Anyone have any ideas on how to make it work.

Thank you
thunderain
 
Use single quote (') rather than pound (#) to delimit the date column.

Is there a reason to use LIKE rather than "=" in the Where clause? LIKE is used when using wildcards to search for strings in a column. LIKE is less efficient that = so it is best to use = if possible. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top