title: SQL Case statement based on dates
body: <p>I need to create a query that includes a CASE statement that basically says </p>
  
  <pre><code>CASE if getdate() &gt; datedue by 31 days
      then status = 'Blocked
  END
  </code></pre>
  
  <p>Does anybody know how to check if todays date is greater than say, 25/10/2012 by 31 days?</p>
  
  <p>EDIT</p>
  
  <pre><code>Select co.OrderID, cu.FName + '  ' + cu.SName as 'Name', 
  cu.Address1 + ', ' + cu.Address2 + ', ' + cu.Address3 as 'Dispatch Address', 
  cu.PostCode, 
  ma.MaterialName as 'Item',
  mi.Price as 'Item Price',
  co.DateOrdered as 'Order Date',
  pm.DueDate,
  pm.Overdue,
  
  HERE I NEED TO WRITE A CASE STATEMENT TO INSERT INTO A LOCKEDACCOUNT TABLE
  so for example CASE WHEN DATEDIFF(dd, GETDATE(), pm.DueDate) &gt;= 31 THEN INSERT INTO LOCKEDACCOUNT (id, status, datelocked, customerid) VALUES (.....)
  END
  
  from Customers cu
  </code></pre>