function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AichaSFAichaSF 

MonthBetween methode


Hello,
I used the monthbetween method to calculate the number of months between two dates and to create, from the contract, a task if the number of months between the end of the contract and today is equal to 3 (batch).
The problem is that I have a contract whose end date s 17/07/2019. at each batch launch I have a task that is created (as it does not take into account the day j).
mukesh guptamukesh gupta
HI Aicha

Please use below code
 
Date a = Date.today();
Date b = Date.newInstance(2019,07,17);// you can add your date field here
Integer monthDiff = a.monthsBetween(b);

If this solution is usefull for you, Please mark as a Best Answer

Regards
Mukesh