title: Date is string between hyphens in SQL Server
body: <p>I have date formats that are as follows:</p>
  
  <pre><code>Date_str
  19-12-2007
  31-7-2009
  3-1-2010
  31-11-2009
  etc.
  </code></pre>
  
  <p>I can't do the following:</p>
  
  <pre><code>CONCAT(RIGHT(Date_str,4),SUBSTRING(Date_str,3,3),LEFT(2)) 
  </code></pre>
  
  <p>because as you can see above, the dates are not the same length. Is there a way in SQL Server to extract the date as datetime/date?</p>
  
  <p>I also tried</p>
  
  <pre><code>Convert(datetime, Date_str)
  </code></pre>
  
  <p>but it just threw an error:</p>
  
  <blockquote>
    <p>The conversion of a varchar data type to a datetime data type resulted
    in an out-of-range value.</p>
  </blockquote>