Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 case in where clause

Author  Topic 

bartos1308
Starting Member

2 Posts

Posted - 2012-11-26 : 13:42:51
can anyone help me with putting a case in the where clause?
i've wrote understanding case. But i get an error and don't know what is wrong. "Dossier.laaddatum" = a field from the database i want the compare.

case
when datepart (dw,getdate()) = 5 then dossier.laaddatum <=getdate() +3 else
when datepart (dw,getdate()) = 6 then dossier.laaddatum <=getdate() +2 else
dossier.laaddatum <= getdate()+1 end

thank you.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-11-26 : 14:14:01
Not exactly sure but maybe this

WHERE dossier.laaddatum <= CASE WHEN datepart (dw,getdate()) = 5 THEN getdate() +3
WHEN datepart (dw,getdate()) = 6 THEN getdate() +2
ELSE getdate()+1
END

Jim


Everyday I learn something that somebody else already knew
Go to Top of Page

bartos1308
Starting Member

2 Posts

Posted - 2012-11-26 : 16:56:24
thank you. it works
Go to Top of Page
   

- Advertisement -