Weekday Date Calculation

732
2
11-02-2018 10:56 AM
ErinGarcia
New Contributor

Is there a way to calculate a date that only includes weekdays, excluding weekend days?

More specifically- I have a 'days to comply' field that has the options: 5, 15, 30.

I'm using the equation now() + ${DaysToComply}*24*60*60*1000 to calculate the date, which works, but I don't want the calculation to include or date to fall on a weekend (or preferably holiday as well!).

ie: today is Friday +5 would be Weds but SHOULD be Friday

ie: today is Tuesday +5 would be Sunday but SHOULD be Tuesday

Would like something similar to the workday function from excel.

Workaround: changed calc options to include weekend days, 5=7, 15=21, 30=42

However, this does not account for holidays.

0 Kudos
2 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Erin,

The approach of working with calendar days is normally the correct procedure.  'Business' days/'weekend' days can vary from region to region and even business to business (as do holidays).  

If needed, the day of the week can be detected via the format-date() function; using that, you can detect whether a day falls on/includes a weekend in the form and add additional days to a calculation.

Holiday detection works best with fixed holidays (such as the 4th of July); the format-date() function can be used to check the date value for a conflict.  Another alternative would be to have a list of holidays accompany the form as a CSV file and use the pulldata() function to lookup a given date.

MichelleWilliams1
Occasional Contributor III

Hi Erin,

This is how we got around the holiday issue. I hope this will help someone down the road.

remember that every 5 days equals a 7 day week.

0 Kudos