954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Syntax Error Near ')'

Hi guys,

I am writing some query from winforms. I am getting error with the following query:

string query = "Select [Doctor Name], Day, DateTime, Med_Sur from Doc_Pat_App where (lower([Patient Name])= '" + name + "') and (DateTime >= GetDate()))";


I know that there is no mistake till lower() function, my mistake is in DateTime >= GetDate() Comparison. Can anybody figure out how can I correct the syntax? my 'DateTime' column is of datatype 'datetime' in sql. Please don't confuse this column name with built-in one.

And one thing more that I want to just compare the date portions of both? Am I doing right or I should use Convert() Function?

I am using sql server 2005.

great_learner
Newbie Poster
23 posts since Apr 2010
Reputation Points: 10
Solved Threads: 3
 

For you syntax error, I think you might have an extra ")" in

(DateTime >= GetDate()))
ctaylo21
Junior Poster in Training
67 posts since May 2010
Reputation Points: 10
Solved Threads: 11
 

You are right! I placed an extra ')' at the end. Thankyou so much! :)

great_learner
Newbie Poster
23 posts since Apr 2010
Reputation Points: 10
Solved Threads: 3
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You