DateAdd - do not add weekends

Hi This looks great! ive tested across 10 different jobs and they seem to calculate correctly.

If it spans over 2 weekends yes I would like it to omit 4 days, does it not?

It does indeed omit 4 days :slight_smile: in the majority of cases.

The only things so far i spotted was if it falls on Saturday its a bit temperamental. - So just need to slightly tweak the case statement in there :slight_smile:

For example :

I would of expected this to have had a delivery date of 04/12/19.

Just a little tweak and should be decent :slight_smile:

Fantastic that’s genius – could you explain to me how it works?

image325026.png

image745634.png

image711792.png

image209680.png

image079666.png

In summary:

Variable 1. Looks at the total days between the 2 dates

Variable 2.Then it off that looks at the number of completed weeks between the “Delivery Date” with 2 methods.
a. Number of completed weeks then multiplies it by 2 (Saturday + Sunday)
b. Number of completed years between the two dates (52 weeks * 2 day weekend)

Variable 3. This total sum of Variable 2 is added to Variable 1

Add Variable 3 to the ShipHead.ShipDate to give you the Delivery date.

The only thing that i have seen so far when playing about with it is that if the delivery falls on a Saturday its deemed an incomplete week (Think a week is Sunday to Sunday - depending on timezone / setup), But sure this can be fixed by just using a case statement and offsetting the calculation slightly

Hope that makes sense ? :slight_smile:

I’m attempting to reverse this so I can subtract days instead of adding, and still land on a weekday. I’ll post if I can figure it out.

This is a quick and easy way to get close. I am in the cloud so I can’t call a function to exclude weekends. I am using this to calculate an Order By column using the lead time. Thank you!

1 Like

Epicor should provide some formulas using a calendar. As they provide a formula to add days to current day. Then we would not need to struggle to find a way to get previous or next work day.

Hopefully be part of the Kinetic version !
Go vote for this idea if not yet done… it is indicated Future consideration…

ERP-1-148 idea

:wink:
Pierre

1 Like