Reply
Regular Visitor
Romulo
Posts: 1
0

Formula to return if current day is a business day

Hi guys,

 

I'm having a hard time with workflow rules running on weekends and holidays. I really wished that Salesforce had the option to only account business days instead of calendar days.

 

I'm trying to workaround this limitation, and I have two formulas:

 

One for returning the day of the week:

MOD(TODAY() - DATE(1900, 1, 7), 7)
This will return a number from 0 to 6 (0 = Sun, 6 = Sat), which you could use to trigger the WFR accordingly

 

Other to check if today is a given holiday:

if (
OR(
today() = datevalue(2012-12-25),
today() = datevalue(2012-12-26)
), 1,0)

 

I'd like to "merge" these two formulas, how can I do that? It would be a formula that checks if current day is different from Sunday and Saturday, AND diferent from one of the holidays, and return "Yes" or "No" to the "Is Business Day?" question.

 

Any help is appreciated!

Thanks in advance!

Regular Contributor
shale
Posts: 86
0

Re: Formula to return if current day is a business day

I think this is what you're looking for:

 

IF(
  AND(
    /* Check for weekday */
    AND(
      MOD( TODAY() - DATE( 1900, 1, 7 ), 7 ) > 0,
      MOD( TODAY() - DATE( 1900, 1, 7 ), 7 ) < 6
    ),
    /* Check for known holiday */
    NOT(
      OR(
        TODAY() = DATE( 2012, 12, 25 ),
        TODAY() = DATE( 2012, 12, 26 )
      )
    )
  )
, 
"Business as usual",
"No work today!")

The first part checks that the modulus is between 1 and 5, and the second part checks that the date doesn't fall on one of the known holidays. It only evaluates to true if both are true.

Shannon Hale
Senior Product Manager, Declarative Apps
Salesforce.com