Skip to main content
Solved

How to add WEEKDAYS only to a date?


Forum|alt.badge.img+11

Hi, is there a way to add weekdays to a date?

E.g. Goods Issue date is on a Friday

and we need to add 2 weekdays (Monday through Friday are weekdays)

to the Goods Issue Date, so that we end at a Delivery Day of Tuesday (Friday + 2 weekdays)

ADD_DAYS would give us Sunday as output, and ADD_WORKDAYS only works with a workday calendar (needs TFACS table which we do not have)

REMAP_TIMESTAMP even with the ADD_DAYS function would bring us to Monday as the next weekday.

Best answer by janpeter.van.d

Hi EnowaVince, I think this script will work: CASE WHEN DAY_OF_WEEK("BKPF"."BUDAT") IN (4, 5) THEN ADD_DAYS("BKPF"."BUDAT", 4) ELSE ADD_DAYS("BKPF"."BUDAT", 2) END The first row checks if the date in the column BUDAT is on a Thursday (4) or Friday (5). If so, the delivery day is then current date + 4, since two days of weekend are in between. If not, only two days are added. This result in a column with only weedays, as is depicted in the appendix. Another option is to specify a workweek in the data model settings (tab Calendar) to use the ADD_WORKDAYS function, but this will also impact the throughput calculations. Hope this works for you! Bests, Jan-peter
View original

janpeter.van.d
Level 8
Forum|alt.badge.img+19
Hi EnowaVince, I think this script will work: CASE WHEN DAY_OF_WEEK("BKPF"."BUDAT") IN (4, 5) THEN ADD_DAYS("BKPF"."BUDAT", 4) ELSE ADD_DAYS("BKPF"."BUDAT", 2) END The first row checks if the date in the column BUDAT is on a Thursday (4) or Friday (5). If so, the delivery day is then current date + 4, since two days of weekend are in between. If not, only two days are added. This result in a column with only weedays, as is depicted in the appendix. Another option is to specify a workweek in the data model settings (tab Calendar) to use the ADD_WORKDAYS function, but this will also impact the throughput calculations. Hope this works for you! Bests, Jan-peter

Forum|alt.badge.img+11

Hi Jan, thank you this worked! Very much appreciated.


Reply