title: Explicit conversion from data type date to int is not allowed
body: <p>I am trying to calculate AGE of contracts, however I am getting the error </p>
  
  <blockquote>
    <p>Explicit conversion from data type date to int is not allowed</p>
  </blockquote>
  
  <p>This is my code:</p>
  
  <pre><code>SELECT 
      Contract_hist.*,
      IB.*,
      CAST((CASE
               WHEN (CAST(CONVERT(INT, Setup.[Start]) - CONVERT(INT,[IB].[Install_Date])) AS INT))/365 &lt;= 0 
                  THEN 0  
               WHEN (CAST(CONVERT(INT, Setup.[Start]) - CONVERT(INT,[IB].[Install_Date])) AS INT)) / 365 &gt; 0 
                  THEN (CAST(CONVERT(INT, Setup.[Start]) CONVERT(INT,[IB].[Install_Date])) AS INT)) / 365 
            END) AS INT) AS AGE
  FROM 
      Setup, Contract_hist
  INNER JOIN 
      IB ON Contract_hist.[System No] = IB.System_ID
  </code></pre>
  
  <p>Where "Setup.[Start]" &amp; "[IB].[Install_Date]" are <em>datetime2</em> values.</p>