Convert 2021_09 date format from string to date

Hello KNIME Community,

I have problems converting strings on the format 2021_09 to a date format. I have tried so far, String to Date&Time node with the Date format yyyy_MM.

I get the error: “Execute failed: Failed to parse date in row ‘Row0’: Text ‘2021_01’ could not be parsed: Unable to obtain LocalDate from TemporalAccessor: {Year=2021, MonthOfYear=1},ISO of type java.time.format.Parsed”

What am I doing wrong?

Hello Robinvm96

My understanding is (please correct me if I am wrong KNIMErs) that you need a date number e.g. 2021_09_01.
Another issue is the String to Date&Time node does not like underscores. e.g it will accept 2021-09-01, it wont accept 2021_09_01. You could change the _ for a - in any number of nodes: String manipulation, Column Expression etc .


Hi Robinvm96,

as FrankColumbo correctly wrote, the values derived from your input (and format) are not enough to create a “Date”. Your input is more like “the whole month of September 2021”, which is not a date.
To explain the rather “raw” error message: it can parse a year and a month value, but nothing else and in order to create a valid date from that, you are missing a component which identifies a specific day (so, Year plus Day-In-Year would also work).

When you input the format in the dialog, there is also an error which tries to tell you that the format is not working to parse a date (lower left in red): “Date needs a date, but does not support a time, time zone or offset!”, which is a kind of generic error if parsing failed (and surely could be improved).

The tooltip that appears when you hover over the format does a round-trip from the current date → string → date and watches for errors, but its message is equally “raw”.

The underscores are supported if you provide the correct format and matching input (with the day):

See the attached workflow:

dateParsing.knwf (10.9 KB)

If you really need a Date object downstream, you can append “_01” to the input and parse it using the format “yyyy_MM_dd”.


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