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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

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.

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

Flowing Fount of Yak Knowledge

2875 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


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

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  
 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.02 seconds. Powered By: Snitz Forums 2000