How to automate this process without having to manually filter dates

Hello everyone,
I already have my work calendar and I want to get the day before the current work day (no days off). I want to use this date as a filter to filter out the number of orders for this date.But I don’t know how to automate this process without having to manually filter dates.

Thanks in advance.

work calendar:

Select the required orders according to the "FinishTime_Arr(0):

Hi @Banksy ,

Although you say “no days off”, do you mean “no weekdays off”. Presumably you are wanting the day before the current work day as it appears on the calendar in your first screenshot? So, if for example today is 2021-01-18 (Monday) then you would want it to return 2021-01-15 (Friday), or am I wrong? I presume this is why you showed the calendar screenshot?

And by current day, do you mean current system date, or will you tell it (e.g. by an input widget/node) what “current day” is?

thanks

3 Likes

Hi @takbb ,
Nice to see you again.
“no days off” is mean Saturday and Sunday are not included, I try use Date& Time shift node, but this node can not get rid of Saturday and Sunday.
And by current day is mean current system date, I use Create Date&Time Range node.

Thanks in advance.

2 Likes

Hi @Banksy (nice to see you too! :wink: )

I don’t know if there is a “single node” solution, to this, but the following might help with getting the previous week day, using a small piece of java to set the value to subtract (-1,-2,-3) according to current day name

Find previous week day.knwf (14.4 KB)
[edit: just re-uploaded so that final node creates new column rather than having it still called just “today” after subtraction]

image

Does that work for you? Did you need assistance with other parts of your problem?

(You can then presumably just do a Join on the “today-previous-day” column output by the above, and “inner join” that to your other table using

FinishTime_Arr(0) = today-previous-day

and that should effectively filter for you

1 Like

Hi @takbb ,
I am so sorry I didn’t explain myself clearly.
The today-previous-day has to be sorted by my work calendar. Because my work calender has eliminated holidays and added weekdays that require work on weekends(Because of the special nature of my country, some of them need to work on weekends).

For example, The day before 2021-2-8 is 2021-2-7, not 2021-2-5.

I create this workflow for work calender, and use Cell Replacer node corresponds to the date of the previous day, and then use Reference Row Filter node filter through this node to get the number of orders for this date. But the previous day’s setup I never found a way.



image
image

Do you have any good ideas, my master.
Thanks in advance.

1 Like

Hi @Banksy, no problem, and my bad as I only quickly scanned the supplied work calendar half way and didn’t pick up on what you were saying.

Anyway, so the problem definition, if I now have this correct is this:

For a given work calendar, find the latest date that is not greater than the day before current date (i.e. not greater than yesterday)

If I define it that way, then what we can do is find yesterday’s date, and use that as a “max” cut-off for the dates in your calendar. Once you have done that, the maximum date remaining in your calendar is the last working day before today…

Here’s a demo that I hope you can slot in to your flow, but let me know if any tweaking is needed. (And by the way, you need more holiday… :wink: )

Find previous working day from work calendar.knwf (24.9 KB)

5 Likes

Hi @takbb ,

That’s what I need, you are so smart. I also know these nodes, but I don’t have the same idea as you.
And I’m new to using variables,no understanding of the rules for using variables. I get the feeling that you know every point. How do you do that?

I incorporated your workflow

So, you save me again, my master. Thank you so much again.

(By the way, I want more holiday too, maybe thinking about going to live in your country,Ha, ha, ha)

3 Likes

Thanks for your kind words @Banksy. There are many people on the forum who know KNIME a lot better than I do, and I am learning from other solutions all the time. According to my forum stats, I have now been visiting the forum for 97 days, which still makes me a relative newcomer to this great tool, and it means that 98 days ago I had not even heard of KNIME! I’ve had the luxury of being able to spend each of those days reading and learning as well as trying to solve problems, and the community here is just awesome.

I would definitely try to learn more about flow variables though if I were you, as there are some things that are difficult or impossible to achieve without them. And… If there is something you don’t understand, you know where to go to ask… :wink:

5 Likes

My master @takbb ,you are always so kind to help me. I am very grteful to you. I guess I still know too little about nodes to simply use them. I don’t know the existence of a node that I haven’t used yet and what does it do. And this forum uses a great platform for people who need help and learning.

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