0

I have field called CBN__c on child object Score and i need to rollup this to the parent account based on Approved Scores. I did create a batch class that updates Account's CBN field but i got a new requirement to not consider/subtract any child CBNs that have Live__date__c between 12/15 and 02/15 of any given years. So i have this formula field on child but how to generalize this without having to subtract year wise.

IF((Live_Date__c >= DATE(2020,12,15) && Live_Date__c <= DATE(2021,2,15))||(Live_Date__c >= DATE(2021,12,15) && Live_Date__c <= DATE(2022,2,15))||(Live_Date__c >= DATE(2022,12,15) && Live_Date__c <= DATE(2023,2,15)), 0 ,IF(ISPICKVAL(Score_Status__c,"Approved"),CBN__c,0))
0

Use functions MONTH and DAY in the formula, to check whether Live_Date__c month and day matches the criteria you are looking for.

In this way, you can keep it generic irrespective of the year in the date.

This formula returns true if Live_Date__c falls between 12/15 and 02/15, this can help you to proceed further :

(MONTH( Live_Date__c) = 12 && DAY( Live_Date__c) > 15) ||
( MONTH( Live_Date__c) < 2 || ( MONTH( Live_Date__c) = 2 && DAY( Live_Date__c) < 15 ))

More info here:

https://help.salesforce.com/articleView?id=sf.customize_functions.htm&type=5 https://help.salesforce.com/articleView?id=sf.formula_examples_dates.htm&type=5

1
  • @user97440 check edited answer with an example to get you started – Shamina Jun 8 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.