title: How to convert ‘std::chrono::duration<int, std::ratio<2629746l, 1l> >’ to ‘int’ type?
body: <p>I am using <a href="https://github.com/HowardHinnant/date" rel="nofollow">Howard Hinnant's date library</a>, and trying to find the total number of months between two dates.</p>
  
  <blockquote>
  <pre><code>invalid static_cast from type ‘std::chrono::duration&lt;int, std::ratio&lt;2629746l, 1l&gt; &gt;’ to type ‘int’
    int period = static_cast&lt;int&gt;(period_in_months(start_date, end_date));
  </code></pre>
  </blockquote>
  
  <p>Here are the functions I am using:</p>
  
  <pre><code>auto period_in_months(year_month_day start_date, year_month_day end_time) {
     auto total_months = ((end_time.year() - start_date.year())*12 + (end_time.month() - start_date.month()));
     return (total_months--);
  }
  
  double percentage_return(string risk_profile, year_month_day start_date, year_month_day end_date) {
     int period = static_cast&lt;int&gt;(period_in_months(start_date, end_date));
     // do something 
  }
  </code></pre>
  
  <p>I tried using <code>chrono::duration_cast&lt;int&gt;(period_in_months(start_date, end_date)</code> but received the same error. </p>