Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

People also ask

How do I calculate the number of months between two dates in smartsheet?

=MONTH(Date@row) - MONTH([Date 2]@row) where Date and Date 2 are the two columns with dates. Check a few use cases to make sure that hangs together. Hi, @ECD Auto Design . The following formula will get you the exact months.


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.

This function would return the number of (say) whole months between d1 and d2.