string to datetime error

Hi guys,

I am not sure what went wrong , it works for month number 1 not for other months. Any help much appreciated. thanks in advance :slight_smile:

error showing in row17

image

What’s the configuration of the String to Date&Time node?

Hi @ArjenEX ,

thanks! screenshot attached.

Allright, change it to yyyy/MM/dd HH:mm:ss and it should be work :wink:

image

2 Likes

Hi @ArjenEX
can you pls explain why ?

The locale that you use in this node is important, hence me asking for your config. en-GB seems to be lowercase dd only.

https://www.localeplanet.com/java/en-GB/index.html

As to why KNIME still converts the dates from January I don’t know, it seems a bit odd to me.

Hi @KaviPriya ,and @ArjenEx,

The reason for it not working is that upper case D or DD is “day of year” rather than “day of month”, which means that all the time the date was in January it was OK, because DD and dd in January are the same thing (in the range 01 to 31).

But when you get to 1st February, and beyond it no longer works. DD for 1 February is day 32 of the year, and so I think when presented with a date of 2022/02/01 but a date mask of yyyy/MM/DD, what is happening is it is trying to create a date in February that contains the first day of the year which is of course nonsensical. The error message is misleading because it talks about conflict with “monthofyear”, but I think this is the actual problem.

"Conflict found: Field MonthOfYear 1 differs from MonthOfYear 2 derived from 2023-01-01"

Actually now as I write, and think about the error message again I guess that technically it is trying to create 1st January (using day 1 of the year) but using February as the month, which is the other way round to what I said above, but the effect is the same :wink: , hence the error about there being a MonthOfYear conflict.

Anyway… you can try this theory out: you can see that it will happily convert 2022/02/32 as 1 February 2022 (i.e the day in February which is day 32 of the year) using that date mask.

image

3 Likes

@takbb

Thanks for the clear explanation :slight_smile:

1 Like

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