title: Converting the name of a day to its integer representation
body: <p>In SQL server you can use the DATENAME function to get the day of week as a string</p>
  
  <pre><code>declare @date datetime
  set @date = '12/16/08'
  select datename(dw, @date)
  </code></pre>
  
  <p>which returns "Tuesday"</p>
  
  <p>and you can use the DATEPART function to get the day of week as an integer</p>
  
  <pre><code>declare @date datetime
  set @date = '12/16/08'
  select datepart(dw, @date)
  </code></pre>
  
  <p>Which returns 3 </p>
  
  <p>But say I have a varchar that contains the string "Tuesday" and I want to convert it to its integer representation of 3. Sure, I could write out the conversion without much hassle, but I'd much rather use a built-in function. Does such a function exist?</p>