How to add 'n' number of days(excluding weekends and holidays) to a given date? We have defined holidays in Database. I know it is possible to define a Process Calendar with a list of non-working days and then use it in caladddays() function to achieve this outcome. As process calendars are not exportable and needs to be created in each environment separately, we are not considering this option at the moment. Having said that is there any alternative way to achieve this result?
Discussion posts and replies are publicly visible
Alright, I found workday() function will help in this regard.
That should help you - my additional thought was, if you're storing your holidays in your database (as opposed to going through the fairly cumbersome and not-very-flexible process of defining them manually within your Appian environment), a brute-force approach would probably be feasible too - i.e. loop over a date range (like with a!forEach) and check each date for its "day of week" as well as whether it's in your holidays DB.
Yea, I have this setup as a recursive function in some areas where additional processing is required. Generally, fn!workday() should cover it, but if we need to expand the logic, a starting example is:
local!dateStart: today(), /* replace with rule input if you do not always want to add from today */
/* make sure you include enough range - get the same # of future holidays as days adding */
pagingInfo: a!pagingInfo(1,local!addDays,a!sortInfo(field: "date",ascending: true)),
rule!chris_test_add_days_recur(date (Date), addDays (Integer), daysAdded (Integer), holidays (List of Date)):
As always with recursive functions, make sure you save your edits prior to testing!
© 2023 Appian. All rights reserved.