Hello,
I want to convert a column from string to datetime but in my column some rows got this “'24/08/2023”, i can’t convert it.
Error message
ERROR String to Date&Time 5:181 Execute failed: Failed to parse date in row ‘Row0’: Text ‘24/08/2023’ could not be parsed at index 0
@etoughet you could try and split the data by the (maybe) length of the string and the use different conversion settings:
Hi @gogon ,
welcome to the KNIME Community Forum
KNIME Analytics Platform has a special data type for date and time information. I would suggest to split your data set into two subsets using a Row Splitter node:
Rows with am/pm format
Rows with 24h format
Next, you can convert the string information into the date&time format using the String to Date&Time node and concatenate the two subset using a Concatenate node.
If you need your time information in string format you can al…
1 Like
takbb
August 29, 2023, 3:40pm
3
Hi @etoughet , what format are the other rows? The mask for 24/08/2023 which would also work with single digit day and month would be d/M/yyyy. What format mask are you using?
If you have 2 very different data formats, then depending on the specific formats of the data, you could also look at this:
Hi @nisha_rathi . Welcome to the KNIME forum.
You can use two String to Date&Time nodes followed by a Merge Columns node.
The first String to Date&Time node tries the date conversion using format string yyyy-MM-dd and appends a new column with suffix d1. Note the capital letters MM for month, as “mm” would be “minutes”.
Make sure Fail on Error is not ticked:
[image]
The second uses format string ‘dd-MM-yyyy’ and appends column with suffix d2:
[image]
The Column Merger then merges the t…
or possibly even this:
Hi @nisha_rathi , you’re welcome. The above was the general answer to handling multiple formats but on further thought there was a simpler solution and it could be achieved with a single String to Date&Time node using the following format mask instead:
[yyyy-MM-dd][dd-MM-yyyy]
The square brackets make parts of the mask optional and so the node would be able to work with both your formats in one go.
system
Closed
November 27, 2023, 3:41pm
4
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.