title: WHERE statement to choose record previous day but choose Friday record when current day is Monday Microsoft SQL
body: <p>I need a <code>WHERE</code> statement where the date of the record is the previous day. I have the below code which will do this </p>
  
  <pre><code>WHERE DOC_DATE =  dateadd(day,datediff(day,1,GETDATE()),0) 
  </code></pre>
  
  <p>However I need this statement to get Friday's record when the current day is Monday. I have the below code but it will not work for me. No errors come back on SQL although no records results come back either. I have the below code for this</p>
  
  <pre><code>WHERE DOC_DATE = DATEADD(day, CASE WHEN datepart(dw,(GETDATE())) IN (2) then -3 ELSE -1 END ,0)
  </code></pre>
  
  <p>Important to add that this needs to be in a <code>WHERE</code> clause. This is for a Docuware administrative view I am creating. I have no control on how to write the <code>SELECT</code> statement, I only have access to edit the <code>WHERE</code> clause:</p>
  
  <p><a href="https://i.stack.imgur.com/qtLfq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qtLfq.jpg" alt="enter image description here"></a></p>