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:
2019-09-24T9:59
2019-09-24T10:59

Modify to:
2019-09-24T10:00
2019-09-24T11:00

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
thanks

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)

5 Likes

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.