hello , In my dataset , I am having a date column with half fields yyyy-mm-dd and half fields are in dd-mm-yyyy i wanted it one format and i.e. yyyy-mm-dd
Hi @nisha_rathi . Welcome to the KNIME forum.
You can use two
String to Date&Time nodes followed by a
Merge Columns node.
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:
The second uses format string ‘dd-MM-yyyy’ and appends column with suffix d2:
The Column Merger then merges the two new columns d1 and d2 into a new column
After that you can use a Column Filter to tidy up
This will give you a date column, which is displayed by KNIME as
yyyy-MM-dd format, but note that a DATE column does not have a “specific format” of its own, and is dependent on the rendering software. If you want your date column to be output in a specific format in a file, for example, you can convert it to a string in the required format using a
Date&Time to String node with the format set to
Thank you so much for your instant solution.
its working. once again thanks.
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:
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.
Very clever, @takbb!