String to date trouble with format

Dear all,

I am reading a csv with a string column containg dates with time, e.g.
2025-04-01
2025-04-15T15:24:30

I try to convert these into Knime date_time format using string to date&time node.
For details please find attched workflow

I expect to convert 2025-04-01 (without time part) to 2025-04-01T00:00:00 instead of getting error

Could not parse date in cell [Row4, column “uninstalldate”, row number 5]: Pattern “yyyy-MM-dd’T’[HH:mm:ss]” does not match “2025-04-15”.

What is wrong?

Thx for help!

BR,

Heinz
test 10 to Knime.knwf (18.8 KB)

Hello @Heinz

The issue with your text $dates$ column is that it isn’t formatted. You have two different formats: ‘Date’ and ‘Date&Time’ in the same column. The ‘String to Date&Time’ node only works one format at a time…

Then there are few different approaches like split the data based on length()…

But the simplest way is an intermediate ‘String Manipulation’ node aiming to shape the string content into an unique text format with 19 characters. The code to be tested would be:

padRight($dates$, 19, "T00:00:00")

BR

2 Likes

Hello gonhaddock,

thank you very much for your answer.
I have implemented string manipulator node. Output after executing this node looks good, but after node string to date time input 2025-04-15T00:00:00 is shown as 2025-04-15T00:00 (seconds are missing)

You can find workflow attached.

BR

Heinz
test 10 to Knime.knwf (19.7 KB)

Hello @Heinz
I saw it in my test. The column is now formatted as ‘Local Date Time’ type, then I think that it’s a matter of display. So you can continue with your workflow double checking, that there’s in not any bug downstream.

BR

if you dont mind using a legacy node, the Column Expression node can solve your issue by applying a if () else () condition, checking for a “T”.

Otherwise, just do a row splitter with CONTAINS “*T*”, and then process both paths independently. for the path without T, you convert to date, and then add a Modify Time node and add 00:00:00, before appending everything together again

3 Likes

Hello @Heinz

Just for the records:
There’s some discussion going on within the following topic; all about displaying Date&Time zero-second’s issue.

:point_right: String to DateTime cuts off seconds if value is zero

BR

1 Like