Current Method for Resetting Variables

I have various Create Date&Time nodes that pass execution date & time to a variable. These nodes work well using KNIME Desktop whenever the whole workflow is reset and run.

However, my use case requires the workflow to be run through Task Scheduler.

The “-reset” in the trigger syntax doesn’t do the trick, but then I read somewhere here that the variables need to be administered via right click workflow name > Workflow Variables.

Two questions here:

  1. Can the variables I created just be entered here, or do I need to create them from scratch and re-point to the global versions of the workflow?

  2. I also read somewhere this whole functionality is legacy and should not be used. So what does someone need to do in order to get a workflow execution run date reset each time?

I realize this is a use case for KNIME Server, but current constraints are such.

Putting down an idea for #2 - guessing I could replace the variable node with an API call for an open date/time service that retrieves today’s date - this way it gets taken out of the variable realm and into the node stream. Though that does seem a bit overkill :cowboy_hat_face:

Hi @qdmt, I haven’t got a specific answer to your question about using Create Date&Time within a scheduled task, but I have an alternative way of getting current Date&Time…

Use String Manipulation node! :slight_smile:

string(new Date())
This will return current date and time as a string as something like:

Mon Aug 14 13:22:47 BST 2023

which can then be converted to a DateTime using the following format mask:

E MMM d H:mm:ss z yyyy

For convenience, I now have this functionality wrapped in a component on the hub:

further information re String Manipulation’s undocumented features here

I don’t know though whether this will assist with your particular problem re Task Scheduler, but I would be interested to know.

2 Likes

Hi @qdmt ,

When you use the create date&time node, you can set the “current time” to update it for “today”. So if you reset it from the flow, you’ll always have the recent date&time, don’t need to change manually.

As a column, you can change it with others nodes as “diff” to adjust the date&time too.

So, I believe that It can help you.

BR, Denis Iongbloed

1 Like

@denisfi I might have not explained correctly, but this is what I do currently and this only works when the workflow is run from the application itself. If the workflow is run via batch / command shell process, the variable will not reset. I’ve seen this documented else where in the forums, and hence ran into the recommendation to use a global variable (which I understand is now legacy, hence this post).

@takbb I will see if I can try that in combination with the Rule Engine node (so far looks like it won’t accept string(new date()). This is currently what I’m doing:

  1. Feed execution date into Rule Engine as variable {expiryshort} (settings exactly as @denisfi shows)
    image

  2. Call the variable in Rule Engine

No, the Rule Engine won’t accept that syntax. I was talking about using String Manipulation, but to use it in combination with Rule Engine, the above component should be able to replace the Create Date&Time Range node.

3 Likes

Cool, thanks very much @takbb!

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