title: Is it OK to use numeric integer value as 3rd argument of DATEADD?
body: <pre><code>SELECT 
      CASE 
          WHEN DATEPART(DW, GETDATE()) = 1 
              THEN DATEADD(WK, DATEDIFF(WK, 0, GETDATE()), -8) 
              ELSE DATEADD(WK, DATEDIFF(WK, 0, GETDATE()), -1) 
      END
  </code></pre>
  <p>This returns the last Sunday. If today were a Sunday, then it will return the prior Sunday.</p>
  <p><code>DATEDIFF</code> always uses Sunday as the first day of the week to ensure the function operates in a deterministic way.</p>
  <p>My question is that - <code>DATEADD</code>'s 3rd argument must be a date. So is it correct to pass numeric integer like -1 and -8 to get the output that I have achieved? I know that SQL internal date is 01-01-1900 (for example: <code>SELECT DATEADD(DAY,0,0)</code>). So -1 will be 1899-12-31 and -8 will be 1899-12-24. But is the above formula deterministic and OK to use to derive the last Sunday?</p>
  <p>Is there a better way?</p>