ICUDateTime for the Previous Business Day

My current guess is:
%ICUDateTimePlus%(DOW() = 1 | DOW() = 2 | DOW() = 7) ? 6 : -1%Days%EEEE%

I got this example by modifying Peter's comment here.

My thinking is... If it's Sunday (1), Monday (2), or Saturday (7), then treat it like it's Friday (6), but otherwise get the day before.

Will this work? I guess I'm not 100% clear on all of the syntax and I don't know how test it without waiting for that specific day

Do you need support for local holidays?

Great point - I can do without any error checking for local holidays

Your calculation has a mixture of the day of the week and the number of days to get to a day of the week. Giving a 6 to ICUDateTimePlus when it's a Sunday will give you the following Saturday. When it's a Monday, it'll give you the following Sunday. Neither of these are what you want. When it's a Saturday, it'll give you the following Friday, which will work, but only because you're formatting the date with EEEE.

My suggestion is this:

%ICUDateTimePlus%DOW() <= 2 ? -(DOW() + 1) : -1%Days%EEEE%

This will go back 1 day for all days except Sunday and Monday. On Sunday it will go back 2 days; on Monday it will go back 3 days.

2 Likes