Add Current Date

Hello,

I need to add one column with the current date. How Can I do it?

Hi @SergioSB , current date and time is something I’d almost expect there to be a dedicated node for, but strangely it’s a little hidden in less obvious nodes. Here are a couple of options

You can use Date&Time Configuration
image

Note that I added a flow into Date&Time Configuration to ensure that it is reset and re-executed if the workflow is re-run to ensure current execution date. Set the return type to Date, and tell it to return execution time.

Variable to Table Column can be used to take the created variable and add it as a new column to your table.

Alternatively, use Create Date&Time Range
image

Have it return execution datetime, and set the return type to Date. You also want it to return just the 1 row (default is 1000 rows!). This can easily then be cross-joined to your data table to add the column. Again I added the flow into the Create Date&Time Range node, to ensure that if the main branch is reset, the node will be reset to get the new execution date.


It’s also possible to do as low-code options using:
Java snippet (returning a Date)

Java Edit Variable (returning a String)

String Manipulation (returning a String)

see Add current date as column – KNIME Community Hub

Re String Manipulation see also Fun with String Manipulation's "undocumented features"

12 Likes

@takbb
I do not think one could give a more detailed and extensive answer. :sweat_smile:kudos

4 Likes

lol, @Daniel_Weikert … I was bored :wink: and I … had the time (literally)

3 Likes

Thanks! I really appreciate it. !

1 Like

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