Derive New Variables from Single Variable Input

As part of the workflow, I want the end user to define a single variable called Start Date. So for example, the end user would input 2023-10-01. From that variable I would like to have additional variables defined that can be used throughout the workflow:

End Date = 2023-10-31
Year = 2023
Month = 10
Period = Oct-23

Hi @matt_mossman , there are a number of ways to achieve this, if you have a variable in yyyy-MM-dd format:

Converting the string to a date (in a table row) allows you to manipulate it using Date&Time to String, and also allows you to use Extract Date Fields which can get you many of the outputs you need.

A low-code option using a String Manipulation “java hack” can easily get you the first and last days of the month for that date too.



Extracting date components from date string.knwf (23.7 KB)

1 Like

Ah I see. So define the variable. Then get that variable into a table so I can create formulas against it & then turn all that back into a list of variables.

Unfortunately yes, if you use the “date” nodes.

KNIME doesn’t have a Date datatype for variables, so as a variable, a date must be stored in a String, which means there aren’t any nodes for Date handling using flow variables.

As shown, you can do it without using table-based date nodes (using the kind of tricks with the String Manipulation (Variable) node as demonstrated. This node could do all of the conversions you need, but the no-code option involves using table-based functions.

Whichever way you go, you will ultimately end up with String variables.