title: SQL Recur every x weekday every x weeks
body: <p>I'm trying to write a sql query which depending on what the user selects will recur every x day every x weeks.
  So the user will select that they want the job to recur on tuesdays every 2 weeks
  the values that are supplied are </p>
  
  <pre><code>declare @StartDate datetime -- when the job first recurs
  declare @recurrenceValue1 int -- amount of weeks
  declare @recurrenceValue2 int -- day of week (mon-sun)
  declare @NextOcurrance datetime -- when the job will recur
  </code></pre>
  
  <p>I know how to set it for the amount of weeks:</p>
  
  <pre><code>SET @NextOccurance = (Convert(char(12),@StartDate + (@RecurrenceValue1),106))
  </code></pre>
  
  <p>But I'm not sure how to make it roll on to the day of the week so if the @startDate is today and it should recur every 2 weeks on a tuesday it will see that 2 weeks today is wednesday so will loop until it know that the day is tuesday and that will be the @NextRecurrance date.</p>
  
  <p>Thanks in advance</p>