title: SSIS expression to find previous Friday
body: <p>Using SQL Server 2008, I have built an SSIS variable with dynamic value base on current date. I would like to have its value to be Friday if the current day is Monday, and here is the expression built:</p>
  
  <pre><code>    DATEPART("dw",GETDATE()) != 2?
  RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD("dd", -1, GETDATE())), 2) + "/" 
      + RIGHT("0" + (DT_WSTR,2)DAY(DATEADD("dd", -1, GETDATE())), 2) + "/" + 
  (DT_WSTR,4)YEAR(DATEADD("dd", -1, GETDATE())) : RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD("dd", -1, GETDATE())), 2) + "/" 
      + RIGHT("0" + (DT_WSTR,2)DAY(DATEADD("dd", -3, GETDATE())), 2) + "/" + 
  (DT_WSTR,4)YEAR(DATEADD("dd", -1, GETDATE()))
  </code></pre>
  
  <p>Issue: it is not accurate when the month or year changed. Is there any better way to do this? Help would be appreciated. Thanks.</p>