I am attempting to pull data from the previous business day. This means that if the workflow is ran on a Monday, then Friday's data will be pulled. I would also like for the workflow to take holidays into account as well. How can I do that? I currently have the below formula to pull from previous business day but it isnt working.
if DateTimeFormat(DateTimeAdd(DateTimeNow(),-1,'days'),'%a') == 'Sun' then DateTimeAdd(DateTimeNow(),-3,'days') else DateTimeAdd(DateTimeNow(),-1,'days') endif
(From another user in the community)
I am not sure how to incorporate holidays.
Please let me know how I can do it.
Thanks,
derm
Maybe this can help?
https://community.alteryx.com/t5/Community-Gallery/Business-Days-count/ta-p/962755
Else generate a list of holidays and append your dataset, and apply a filter?
Hmmm I don't think this is what I'm looking for. The data I'm pulling from only has business days in it. What I meant was a formula or filter that could be ran daily and that would only show data from the previous business day. So, if I ran the workflow on a Monday, Friday's data would be the only data I see. If ran on Tuesday, I'd get Monday's data.
@derm one way of doing this
@dermHere is one proposed solution:
Step1: Create a field DayofWeek (integer data type) = ToNumber(DateTimeFormat(DateTimeNow(),"%u"))
Step 2: Extract Prev Business Day value using this formula:
IF [DayofWeek]>=2 AND [DayofWeek]<=6
THEN DateTimeAdd(DateTimeNow(),-1,"day")
elseif [DayofWeek]=7
THEN DateTimeAdd(DateTimeNow(),-2,"day")
else DateTimeAdd(DateTimeNow(),-3,"day")
endif