title: SQL Server : how to convert float yyyymmdd to date yyyy-mm-dd?
body: <p>In other posts you advice to use</p>
  
  <pre><code>TO_DATE(your_date as String, 'YYYY-MM-DD')
  </code></pre>
  
  <p>but in SQL Server there is no function <code>to_date</code> :(</p>
  
  <p>I tried something like this:</p>
  
  <pre><code>select 
      start_date2 = replace(substring(cast(start_date as varchar),1,5),'.','') + '-' +
          case when substring(cast(start_date as char),6,2) ='1e' then '10' else substring(cast(start_date as char),6,2) end + '-' +
          cast(substring(cast(start_date as char),8,2)as char)
  from 
      my_table
  </code></pre>
  
  <p>but it returns for example:</p>
  
  <pre><code>1971-05-e+                            
  </code></pre>
  
  <p>instead of: </p>
  
  <pre><code>1971-05-08                           
  </code></pre>