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
NyshaaNyshaa 

Criteria to fetch the end date one month after the date has past.

What will be the criteria if the date has already ended one month ago.
i.e One month after the contract end date is past

Thanks in Advance!

AnudeepAnudeep (Salesforce Developers) 
You could do something like this
 
DATE( Year([start date])+floor((MONTH([start date]) + [# of months] - 1) / 12) , 
    mod(MONTH([start date]) + [# of months] -1, 12) + 1 , 
     day([start date])
) - 1

In general if you want to retrieve past months date if you would do something like this
 
Lead ld = [Select CreatedDate from Lead limit 1];

System.debug('lead created date is' + ld.CreatedDate);

Datetime leaddate = ld.CreatedDate; 
Datetime sixmonthsearlier = leaddate.addMonths(-6);

System.debug('6 months before date is' + sixmonthsearlier); 

Opportunity opp = [select id from Opportunity where CreatedDate>=:leaddate AND CreatedDate <=:sixmonthsearlier limit 1];

Let me know if this helps, if it does, please close the query by marking it as solved. It may help others in the community. Thank You!
Wilkinson WilkinsonWilkinson Wilkinson
Thanks, Anudeep,
Thanks  for the solution keep sharing such informative post, i will recommend this post to others Mypascoconnect (https://www.targetpayandbenefits.me/)