Requirements:
- Calculate the number of months between two dates: receiveDate and dueDate.
- Both optimistic and pessimistic calculations are needed
Assumptions:
- dueDate will always be the last day of the month.
I've already figured out the pessimistic calculation (meaning a single day overdue counts as a whole month:
if(receiveDate > dueDate)
receiveDate.Month - dueDate.Month + (receiveDate.Year - dueDate.Year) * 12;
Doing a search on the internet turned up several similar examples to confirm this.
Now my instincts tell me the optimistic calculation will just be the same minus one month but for some reason it just doesn't feel right. Am I on the right track or am I missing something?