Excluding Saturdays and Sundays

Hello,
In a workflow for order planning, I calculate a production date from a delivery date (received by the customer) via Date & Time Shift Node:
Manufacturing date = delivery date - 3 days.

Saturdays and Sundays are also included, which I would like to exclude (no working days).

Example:
Delivery date = 22.06.2021
Manufacturing date = 22.06. - 3 days = 19.06.2021 (Saturday)

The next day of the week would then have to be set via a condition, in this example it would be 06/18/2021 (Friday).

Is that possible and if so, how?

Thx in advance

datetimeshiftnode

Maybe this How get working day without weekend - #5 by Banksy may give some answer to your question

1 Like

Hi USCHUKN1ME,

I’ve whipped something up real quick and I hope it gets close to what you are aiming at. Workflow attached, here’s what I’ve done:

  1. Created dates as provisionary manufacturing dates, named the column “date”
  2. Appended column with manufacturing date shifted +3d, named it “date_delivery”
  3. Extracted day of week of “date_delivery”
  4. Rule Engine: if day of week = 6 => -1, if day of week = 7 => -2, else 0
  5. Shifted “date” by number of days from Rule Engine. Saturdays and Sundays become the previous Friday, named this new column “date_manufacturing”

temp-33788.knwf (17.1 KB)

The last two nodes are optional. If you don’t have any deliveries on Sunday, you could exclude the 7s from the day of week column before the Rule Engine. I only noticed afterwards and couldn’t be bothered to change the order of nodes again. I think you get the idea. The resulting table could then be joined with the table containing the dates you use.

1 Like

If you can then use Extract Date Time Fields node like @G47_2 pointed out.
If not I would use a code snippet node

@G47_2 and @knimediger ,

thank you very much - it helps me a lot :smiley: .

I’ve integrated the wokflow, adjusted it a bit. Everything’s working perfectly.

Thx !!!

Ermittlung_Änderung_fertigungsdatum_wenn_Samstag_oder_Sonntag.knwf (52.9 KB)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.