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
Rob LilleyRob Lilley 

Formula to create a record for the next/following Monday

Hello, I wonder if anyone can help please?
We have a custom object 'Payment' that is a child of the Opportunity. There is currently a process builder that creates a payment record when the following Opportunity custom fields are updated.
Grant Amount (currency) and Decision Date (date).

The payment record will be created with a Paid Amount = Grant Amount on Opportunity and Payment Date = Decision Date on Opportunity.
What I would like to do is have the Payment Date set to the next or Following Monday (ie the Monday following the Decsion Date).

Is this possible? Many thanks, Rob 


 
Best Answer chosen by Rob Lilley
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Rob,

Can you check the below formula for the above.
 
IF(WEEKDAY(DateField__c) = 2 ,DateField__c , DateField__c + (8 - MOD( DateField__c - DATE(1900, 1, 7), 7 )))

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
 

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Can you try the below formula.

 
DateField__c + (8 - MOD( DateField__c - DATE(1900, 1, 7), 7 ))

Thanks,
Rob LilleyRob Lilley
Thanks Sai, that appears to work fine, thank you. I need to check that if this is inputted on a Monday the formula does not produce next Monday. It should default to the Monday date that it is inputted. 

Best wishes, Rob 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Rob,

Can you check the below formula for the above.
 
IF(WEEKDAY(DateField__c) = 2 ,DateField__c , DateField__c + (8 - MOD( DateField__c - DATE(1900, 1, 7), 7 )))

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
 
This was selected as the best answer
Rob LilleyRob Lilley
Hi Sai,

That's great. Works very well, thank you, Rob