Rounding time to the nearest hour

Hi, I was trying to modify a time-series dataset, round the time to the nearest hour, like below:

original timestamp:

Modify to:

Any idea on how to do this with Knime nodes? I didn’t find suitable method, I’m using Python codes to modify in the desired way but Python nodes cost a lot time in Knime execution

A problem with your data is that your timestamps do not have a consistent width on hour (i.e you have “9” and not “09”) - so this prevents you from using the String to Date&Time format.

Attached is a workflow that provides for the case in which you have this poor formatting, as well as one in which you have a standardized formatting… dealer’s choice.
xiaoanxie’s rounding.knwf (11.7 KB)


Thanks for your quick response!! There is a typo in my original data…it should be “09”…but your Java node done the job greatly. Appreciate

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