number of months between two dates - using boost's date

Posted by MartinP on Stack Overflow See other posts from Stack Overflow or by MartinP
Published on 2010-04-26T15:29:11Z Indexed on 2010/04/26 15:53 UTC
Read the original article Hit count: 244

Filed under:
|
|

I've used boost::gregorian::date a bit now.

I can see that there are the related months & years & weeks duration types. I can see how to use known durations to advance a given date.

Qu: But how can I get the difference between two dates in months (or years or weeks) ?

I was hoping to find a function like:

template<typename DURATION>
  DURATION date_diff<DURATION>(const date& d1,const date& d2);

There would need to be some handling of rounding too.

© Stack Overflow or respective owner

Related posts about c++

Related posts about date