Extract Time from multiple date/time columns with one node?

I have tried search unsuccessfully for a way to use a single node to pull out the hours information from multiple date time columns. the only solution I have figured out is to do do multiple Date Time extract nodes in series which isn’t very dynamic.

I guess this could be done with some type of Loop, but I was hoping there was a catch all node/component that could do this for multiple fields at once.

Any suggestions?

if the number and names of the columns is fix, then you can do the following:

  • chain multiple nodes like you did
  • use the Column Expression Node and create an extraction for each column (comment here: Knime depreciated this node but did so before making date, time and datetime functionalities available in their successor node)

If the columns change every so often, you are better of to

  1. use a Column Splitter and split them by type
  2. pipe the datetime columns into a Column List Loop Start
  3. Extract the time, maybe rename the column
  4. Loop End (Column Append)
  5. Column Appender

Further, if you want the time as full time value instead of the hours only, you are better of using “Modify Date” node (set it to “Remove Date”). That node can process all columns at once.

If you dont need it as number value but are fine with Strings, you can even go as far as using the Date&Time to String node and simply set it to “HH”

2 Likes

Hi,

I believe, an Unpivot followed by a Date Extract and then a Pivot should efficiently handle this. If you’re working with multiple date columns, this approach will be especially useful.

For your convenience, I’ve uploaded a sample dataset and the corresponding KNIME workflow. Hope this helps!

Let me know if you have any questions.

Best,

Alpay

KNIME_Project_ExtractTimefrommultipledatetimecolumnswithonenode.knwf (19.2 KB)
CP.xlsx (4.8 KB)

3 Likes

Thanks I started playing around with this option, after I posted. this worked great.

1 Like

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