title: SQL: get next relative day of week. (Next Monday, Tuesday, Wed.....)
body: <p>What I need is a date for the next given day (Monday, Tuesday, Wed...) following today's date.</p>
  
  <p>The user is allowed to select what day following they want and that is stored as an int in a table. "Call me next Tuesday (3)"</p>
  
  <pre><code>Sunday = 1
  Monday = 2
  Tuesday = 3
  ...
  </code></pre>
  
  <p>So my table looks like this.</p>
  
  <pre><code>UserID, NextDayID
  </code></pre>
  
  <p>What I have come up with is:</p>
  
  <pre><code>select dateadd(dd,(7 - datepart(dw,GETDATE()) + NextDayID ) % 7, getdate())
  </code></pre>
  
  <p>It seems to work and will return today's date if you ask for the next whatever day today is which I can add a week if needed.</p>
  
  <p>What I am wondering is, is that a good solution or is there something that I'm missing?</p>