@ArjenEX @Pedro87 , that’s a good way to do this, but bear in mind that this will work only for input dates of yyyy-mm-dd, which is the case here.
A more robust and more generic way is to apply this after the String to Date&Time and with the Extract Date&Time Fields node.
First of all, I want to make sure that @Pedro87 understands that Knime does not output dates in different date formats, therefore if you want to change the format, the result will be a string type, not a date type.
Something like this will allow you to process any date format without having to change the logic:
Input:
Output:
Logic used is this (I’m using String Manipulation):
join(padLeft(string($Day of month$), 2, "0")
, "-", padLeft(string($Month (number)$), 2, "0")
, "-", string($Year$)
)
And this will work for this input too:
You just need to specify what date format the input is in the String to Date&Time, and nothing else:
You get the same expected results:
This works because the Extract Date&Time Fields will extract that correct values of year, month and day following the specified format for String to Date&Time. I don’t have to change the logic that I showed above.
Here’s the workflow:
EDIT: @ArjenEX , sorry I missed your first option, I thought it was just a “demo” to swing between dates and string for @Pedro87 , and thought your solution was what you suggested in the Column Expression.
I’ve now realised that the String to Date&Time + Date&Time to String was actually a solution (I was playing around on my side and also came up with this), and a brilliant one actually.
You should share your workflow so we can see what’s really happening there