Tuesday, 27 June 2023

Due Date calculation formula for excluding weekends in flow

 Hi ,

The following formula field calculates the Due Date provided the Today() date and numberOfDays to be added to the Today() date excluding Saturdays and Sundays in the flow.

CASE(

MOD(TODAY()  - DATE(1900, 1, 7), 7),

0, (TODAY() ) + numberOfDays + FLOOR((numberOfDays-1)/5)*2,

1, (TODAY() ) + numberOfDays + FLOOR((numberOfDays)/5)*2,

2, (TODAY() ) + numberOfDays + FLOOR((numberOfDays+1)/5)*2,

3, (TODAY() ) + numberOfDays + FLOOR((numberOfDays+2)/5)*2,

4, (TODAY() ) + numberOfDays + FLOOR((numberOfDays+3)/5)*2,

5, (TODAY() ) + numberOfDays + CEILING((numberOfDays)/5)*2,

6, (TODAY() ) - IF(numberOfDays>0,1,0) + numberOfDays + CEILING((numberOfDays)/5)*2,

null)


Here numberOfDays is flow variable.


Example Scenario:

When an Account is created, a task should be created with a due date set to 5 days from today.

Reference:

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

No comments:

Post a Comment

What’s the difference between Einstein Article Recommendations and Suggested Articles?

How Does Einstein Article Recommendations Work? Einstein Article Recommendations helps support agents resolve customer cases efficiently by ...