Day/Date Manipulation based on conditions - Move Forward or Backward

Hi Everyone, I need some suggestions on how I can perform this date manipulation on KNIME.
I am thinking Column Expression Node would be the go-to but I cannot wrap my head around a formula. Hoping that someone can share their knowledge.

I have a data set with only 2 columns Fixed Packing Day (FPD) and Requested Packing Dates (RPD),
FPD has values like Mon, Tue, Wed etc. with no date values, purely Name Of Day values.
RPD has date values with no Name Of Day values.

I need to shift the Requested Packing Date to the nearest Fixed Packing Day so that the difference in dates is no more than ± 3 days.

For example, assuming FPD is a Tuesday.
If RPD is 11th July 2023 (= Wednesday).
To keep within the ± 3 days adjustment, move RPD to 10th July 2023 (Tuesday) = Difference -1.
Moving the RPD to the next Tues on 18th July would be too much of a difference.

I have attached an excel file with 2 scenarios, I am trying to achieve the correct Adjusted Date.
Can anyone help please?

Thank you!
20230713_Date Manipulation.xlsx (10.9 KB)

I can’t understand your Excel file. 2023-7- 12 is Wednesday, not Tuesday. The column header is in row 0 rather than being a real header. Your dates are strings rather than date format. All this is fixable, but if you want help, it would be nice if you provide clean data.

1 Like

Hi @rfeigel , Thanks for pointing out that 7/12 is actually a Wednesday. Oversight on my part.
I understand the data is not ideal but it was not meant to be an actual dataset.
I was attempting to illustrate a scenario with the file rather than provide a dataset to work with.
There are no real formulas within the sheet, and it was manually input to reflect the desired adjusted date.

Nonetheless, thanks for the advice, and I will take note of that moving forward.

I’m not sure I fully understand your issue, but try the attached workflow. It may give you some ideas.

1 Like

@neekstressed Did my post help with your problem? A reply is only common courtesy.

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