Last post Aug 21, 2012 09:13 PM by Decker Dong - MSFT
Aug 20, 2012 03:04 AM|SudhaRubini|LINK
i got Incorrect syntax near '='.
what mistake i done there...... please any one help me
select * from tngf_CMS where ModuleId = 77 and Flag = 1 and Status = 1 ORDER BY CONVERT(datetime, EleventhContent == null ) THEN CONVERT(datetime, FourthContent < GetDate()) ELSE CONVERT(datetime, EleventhContent < GetDate)
Aug 20, 2012 03:28 AM|Prashant Kumar|LINK
The order by clause is wrong. You cannot use ==
What are you trying to order by? Can you explain?
Aug 20, 2012 03:43 AM|SudhaRubini|LINK
i want the date in order. i get the record in database for based on two condition.
Two column field. first column is my start date. second column is end date.
if user give only start date mean
fitst column field based data to be display
this case was execute.
string date = "CONVERT(datetime, FourthContent,101)";
order = "ORDER BY CASE WHEN (" + date + " < GetDate()) THEN 1 ELSE 0 END,(CONVERT(datetime, FourthContent))";
if first and end date mean i want to display data based on end date .
Aug 21, 2012 09:13 PM|Decker Dong - MSFT|LINK
As far as I see——
1）== can be used in C# instead of SQL syntax. And you cannot use == or = directly in the SQL statement. You have to use "Is" instead.
2）case can be used like this：
select * from xxx
case when [YourDateTimeField]<getdate() then 1