Function: Add/Subtract Workdays from a date

Would it be possible to have an Add/Subtract number of workdays function?

Here is the use case. Our company performs equipment installations that have specific stages for milestones. I need to be able to forecast how shifting schedules, pull-in priorities, push out delays will effect milestones as well as final completion. But there are instances where work is not performed on weekends.

I know we have a workdays function that calculates the number of workdays between two dates. But I am looking for something that starts off with a single date and then calculates the new date based on how many workdays I would like to add/subtract. In my time zone today is Wednesday 2026-07-29 and if I wanted to say add 9 workdays to that it would be 2026-08-11 even though there is a total of 13 days difference.

You can do so with standard easymorph functions. Assuming the variables are SomeDate, NumWorkdays, and WorkdaysInWeek (4, 5 or 6, depending on whether Friday and Saturday count as a workday in your country/company), the logic is (sorry, can't prvide easymorph code, as I'm on holiday):

  • NumWeekends = integer division(NumWorkdays - weekday(SomeDate), WorkdaysInWeek) + 1
  • TargetDate = SomeDate - 2*NumWeekends - weekday(SomeDate)

This will need tweaking for weekday start in easymorph, and *assumes NumWorkdays is always longer than WorkdaysInWeek.

Do you also mean to take into account public holidays? That can also be done, but that gets trickier.

Hi Sir-McNeil,

Thank you for taking the time out of your day to write this up. And on your holiday none the less.

I will try to play around with this method a bit.

I imagine trying to account for national holidays would get a bit muddy and I don't have a specific use case for holidays at the moment. But it may good to have for posterity at some point.

Please have an excellent rest of your holiday. I hope you are somewhere nice and with good people!

Best-

It depends. What I’ve done so far (which is also not entirely without effort): I load the data via API. In Germany, for example, there is https://www.api-feiertage.de/. You can select both the nationwide valid holidays and the holidays for each federal state. That way you can determine the holidays quite easily. I'm sure that there are such pages for your region, too.

Another option: if you have an ERP system like SAP, you can extract these informations from the fabric calendar.

@Jochen_Marquardt

Thank you for the reply! Yes, I handle regions in both the US and Japan and the holidays can become complicated. Though, I think I can either pull it from SAP (wonder if our MM guys have this somewhere lol). But I imagine getting specific holiday days to work with the above formula may be pretty tricky.

Now that I thinking about this some more, I am wondering if another method to handle this would be to create a separate module and generating a calendar with some kind of range and then using the weekend flag to filter out those records. And then removing holiday days and enumerating the rows and keeping just the record where the enumerated value matches the number of workdays I am looking to add/subtract.

Anyway, thank for the idea and getting me thinking about alternative methods!

Best wishes,

Sean Perkins

At SAP, it would be table TFACS and THOCS.I think it is not the most complex way to get the workdays.

TFACS US and JP.xlsx (4.6 KB)

THOCS US and JP.xlsx (4.5 KB)

Here are the entries for USA and Japan. Every month has one column.

In table TFACS, every '1' stands for workday. In THOCS holidays are displayed as 0. I guess, it's pretty easy with easymorph. :smiling_face_with_sunglasses:

Thank you sir!! I will need to check these out in our implementation. I appreciate you taking the time to take a look on my behalf.

Best-

Just in case, the workdays() function has two optional arguments - "dates to exclude" and "dates to include". The "dates to exclude" can contain a comma-separated list of dates, such as public holidays, that should be excluded when counting workdays.

Examples here: Workdays(from_date, to_date, [exclude],[include]) [EasyMorph Help]

We will soon add a similar addworkdays() function with similar logic.