Issue while converting into Date format

Hello Knime Experts…

Hope you are doing well.

Basically i am facing issue as follows while convert string format into Date & Time format:

Input data i am getting in YYYYMMDD format(String) ,
Input Date(string format)
20200127
20200128
20200129
20200130

then i am converting into Date & Time format + adding “-” to seperate year,month & date.

Input Date(Date & time format)
2020-01-27
2020-01-28
2020-01-29
2020-01-30

After conversion, i am converting it into String,
Input Date(string format)
2020-01-27
2020-01-28
2020-01-29
2020-01-30

And after this,
I am using following formula to convert into final output requirement:
In String manipulation
join(substr($Entry Date$, 8,2), “-”, substr($Entry Date$, 5,2), “-”, substr($Entry Date$, 0,4))

But its not converting.

Final Output requirement:

Input Date(Date & Time format)
27-01-2020
28-01-2020
29-01-2020
30-01-2020

Pleas guide.
Thanks in advance.

Hi @ravi13
You can achieve this by using a String to Date&Time node and a Date&Time to String node

Suppose your workflow is like this:
afbeelding

Configure the String to Date&Time node like this:


And the Date&Time to String with this:
afbeelding

The input (on the left) will give the result (on the right)

afbeelding

2 Likes

Hi!! @JanDuo
Thanks for the reply.
I will check this solution & come back to you.

@JanDuo whether output is in Date & time format or String format ?

i want output into Date & Time format.

Using just the first node will give you a date format already. You can recognize this on the small icon shown in the data table.
afbeelding

The format which is used to display this date format is the standard ISO-format (yyyy-MM-dd). If you want to deviated from this standard format, the only option I know of is to change it into a string of your liking (as I showed earlier).

2 Likes

@JanDuo Correct & Thanks for explanation, but i want into DD-MM-YYYY format, because further i want to make certain calculation w.r.t. Date.

@ravi13 if you want to make date calculations you can use standard nodes from the Node Repository.

afbeelding

For these you should leave the format as is. If you need to get certain parts from a date the Extract Date&Time Fields node might become useful for you.

4 Likes

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