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
Sujit KarandeSujit Karande 

Check the date is 1st day of month and set the value

Hi All,

I have a Date field in opportunity object say "Renewal Date

I want to create a formula field say "Final Renewal Date"(Because it needs to add into the report to show the final renewal date for existing opportunities)

What I am trying to achieve is 

If (Renewal Date == 1st day of month)        // For eg : 1 Aug 2018
{
     Final Renewal Date should be last day of previous month          // It should be 31 July 2018
}
else 
{
   Take renewal date as it is to the Final renewal date
}

Can we achieve this? It's so urgent, I stuck completely. Please help me :(
Steven NsubugaSteven Nsubuga
IF (DAY(RenewalDate__c) == 1, RenewalDate__c - 1, RenewalDate__c)

 
Steven NsubugaSteven Nsubuga
Hi Sujit, please mark it as a best answer if it helped. Thanks
Sujit KarandeSujit Karande
Hi Steven, Appreciate your help.

But how should we assign Last day of the month to Final Renewal Date after checking for the 1st day of the renewal date
Steven NsubugaSteven Nsubuga
Final Renewal Date should be a formula field with a date return type.
I am assuming that RenewalDate__c is the date field with the initial Renewal Date that is used to determine the final renewal date.

What I shared was the syntax to use in defining the formula.
IF (DAY(RenewalDate__c) == 1, RenewalDate__c - 1, RenewalDate__c)