I have read the existing threads on the subject but can't seem to make a simple 'IF' statement work in MS Query with a single table. I always get the following error:
Returns error message:
"Incorrect syntax near the keyword 'if'
Incorrect syntax near ','.
Statement(s) could not be prepared.
Here's my query (simplified, but not much):
select *
from table t
where t.modifieddate > if(t.active=0, date1, date2)
Just to see if I could get AN if statement to work, I've also tried:
SELECT t.active, if(t.active=0,2,3)
FROM CdmsTimeSheet.dbo.Registrations t
And
SELECT t.active, if(t.active='0','2','3')
FROM CdmsTimeSheet.dbo.Registrations t
And
SELECT t.active,
FROM CdmsTimeSheet.dbo.Registrations t
where datemodified>if(t.active='0',3/1/2014,1/1/2014)
and
SELECT t.active,
FROM CdmsTimeSheet.dbo.Registrations t
where datemodified>if(t.active='0',#3/1/2014#,#1/1/2014#)
I've been using excel/ms query for many years but not in the last year or two and am wondering if this was somehow removed? I tried using decode but then get a "not built-in function" error.
Please help! Thanks