Set a certain date as "today's" date

Hi,
I’ve been trying to find out if it’s possible to “fool” KNIME on what’s the current date.

I have many Java Snipet nodes that contain the method java.time.LocalDateTime.now() .This works when the data I’m using actually belongs to that day.

However, in order to accurately run my model with data from previous dates, I would like KNIME to “believe” that the current date is one of my choice.

Is there any way to achieve this? Due to the size of my model, it would be a lot of work to set a certain date in every single node.

Cheers!

The only way to do this is to set another time as current time in your operative system.
But generally this is not a good idea.

According to me, the problem is entire workflow.
If you have “a lot of nodes” dependent by current date, this is a problem.
If you want your process is right, you have to build your nodes dependent by a single variable that you can set with current date or with custom date. In a single point.

According to me you have to refactor your process in this way.

4 Likes

I also would suggest to change your workflow like pigreco said.
Fixing it with fooling KNIME about the current date will only cause further problems :zipper_mouth_face:

1 Like

Thanks a lot for your suggestions.
I rather not re-configure all of my nodes, unless it’s the only option (it really is lots of them).
@AnotherFraudUser , what kind of problems would it cause to fool KNIME?

Hi Francisco_munoz_m,

this kind of change will for once make the understanding and maintenance of the workflow a nightmare.
Anybody beside you will have a hard time to do anything and you in a few month/years will most likely not know that this was done.
Additionally if you do this “fooling” most likely this workflow will only run on the set time for your pc alone (while everyone else will have the real current date).
Additionally when you do this, you will also affect all your other workflows, not only the one you indend to fool
Additionally (depending how you do it) other programms beside knime will be affected as well (which most likely will not like that)
Additionally as you currently experience… you might want to change the date again multiple times in the future - so it would most likely easier to just make your workflow variable for future usages
As well I guess features like server connection / Knime Updates / certain extensions might not work anymore

It also might not cause any problems, but it would most likely be an ugly workaround :slight_smile:

1 Like

Hi there @francisco_munoz_m,

welcome to KNIME Community!

Don’t think it is necessary that re-factoring will take a lot of time. If you do as @pigreco suggested (with which I strongly agree) you can create your current data at beginning of workflow and have it in flow variable so to be available in all downstream nodes. Then each Java Snippet needs same replacement. Use Control + F to find all Java Snippet nodes :wink:

Br,
Ivan

2 Likes

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