title: SQL convert date nvarchar datatype to float
body: <p>I have an excel file that contains a column date, in the excel it is formatted as date.</p>
  <p>It is included in a SQL database, unfortunately I have no influence on the procedure.</p>
  <p>In the SQL database the following command is executed:</p>
  <pre><code>WHEN YEAR(CAST(CAST(REPLACE(redatum, ',', '.') AS float) - 2 AS datetime) AS date)) &lt;&gt; @YEAR
       THEN DATEFROMPARTS(@YEAR, 12, 31) 
       ELSE CAST(CAST(REPLACE(redatum, ',', '.') AS float) - 2 AS datetime) AS date) 
  END redatum
  </code></pre>
  <p>And I get the following error message when I run it.</p>
  <blockquote>
  <p>Error converting nvarchar datatype to float.</p>
  </blockquote>
  <p>Are there any tips on how to fix this error?</p>
  <p>Thanks a lot</p>