SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 case in where clause
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bartos1308
Starting Member

2 Posts

Posted - 11/26/2012 :  13:42:51  Show Profile  Reply with Quote
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.

Edited by - bartos1308 on 11/26/2012 14:01:06

jimf
Flowing Fount of Yak Knowledge

USA
2870 Posts

Posted - 11/26/2012 :  14:14:01  Show Profile  Reply with Quote
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 - 11/26/2012 :  16:56:24  Show Profile  Reply with Quote
thank you. it works
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000