title: Get previous Tuesday (or any given day of week) for specified date
body: <p>I want to get previous Tuesday (or any given day of week) for specified date. Here is the sample input and expected output for Tuesday:</p>
  
  <pre><code>CREATE TABLE #temp(testdate DATETIME);
  INSERT INTO  #temp(testdate) VALUES
      ('2015-10-06 01:15'), -- Tue -&gt; Tue 2015-10-06 00:00
      ('2015-10-07 04:30'), -- Wed -&gt; Tue 2015-10-06 00:00
      ('2015-10-08 00:30'), -- Thu -&gt; Tue 2015-10-06 00:00
      ('2015-10-09 21:00'), -- Fri -&gt; Tue 2015-10-06 00:00
      ('2015-10-10 19:00'), -- Sat -&gt; Tue 2015-10-06 00:00
      ('2015-10-11 01:15'), -- Sun -&gt; Tue 2015-10-06 00:00
      ('2015-10-12 13:00'), -- Mon -&gt; Tue 2015-10-06 00:00
  
      ('2015-10-13 18:45'), -- Tue -&gt; Tue 2015-10-13 00:00
      ('2015-10-14 12:15'), -- Wed -&gt; Tue 2015-10-13 00:00
      ('2015-10-15 10:45'), -- Thu -&gt; Tue 2015-10-13 00:00
      ('2015-10-16 04:30'), -- Fri -&gt; Tue 2015-10-13 00:00
      ('2015-10-17 12:15'), -- Sat -&gt; Tue 2015-10-13 00:00
      ('2015-10-18 00:30'), -- Sun -&gt; Tue 2015-10-13 00:00
      ('2015-10-19 10:45'), -- Mon -&gt; Tue 2015-10-13 00:00
  
      ('2015-10-20 01:15'), -- Tue -&gt; Tue 2015-10-20 00:00
      ('2015-10-21 23:45'), -- Wed -&gt; Tue 2015-10-20 00:00
      ('2015-10-22 21:00'), -- Thu -&gt; Tue 2015-10-20 00:00
      ('2015-10-23 18:45'), -- Fri -&gt; Tue 2015-10-20 00:00
      ('2015-10-24 06:45'), -- Sat -&gt; Tue 2015-10-20 00:00
      ('2015-10-25 06:45'), -- Sun -&gt; Tue 2015-10-20 00:00
      ('2015-10-26 04:30'); -- Mon -&gt; Tue 2015-10-20 00:00
  
  DECLARE @clampday AS INT = 3; -- Tuesday
  SELECT -- DATEADD/DATEPART/@clampday/???
  </code></pre>
  
  <p>What is the most appropriate way to get the previous Tuesday (or any day of week) using T-SQL?</p>