title: SQL Server 2012 - Case statement in where clause
body: <p>SQL is not my strong suit, but I cannot figure out why this isn't working. I simply want to run a different AND statement based on a value. Specifically, I want to change the datePart in the dateDiff function if foo is = 0</p>
  
  <pre><code>SELECT foo,
         bar,
         test
  FROM table
  WHERE bar = 1,
  CASE WHEN foo = 0
          AND dateDiff(dd, getDate(), 2 ) &lt; test
  ELSE
          AND dateDiff(hh, getDate(), 2 ) &lt; test
  END
  </code></pre>