String to date - month name not recognized (MMM)

I read another post in which this works, and should work, but may be not anymore.
I have Dec-2015 which a String to Date node should read as MMM-yyyy, but doesn’t work like that.
Any tips?

image

Hi @deicide_bg -

After playing around with this a bit I noticed a couple of things:

  1. the node doesn’t like an input of only month and year - this makes sense, since what is it supposed to assume about the day? If you edit the string to include a day, it will work, with an additional caveat…

  2. The node doesn’t like uppercase for the months (DEC as opposed to Dec). It has to be mixed case, which I suspect is a requirement of the underlying library.

Did the format you mention above work in the past? If so I’d be curious to see an example.

5 Likes

I think this describes a case in which that works:

That example includes a day, though (2-digit dd at the beginning of the string).

So just a partial date string wouldn’t be recognized, and needs a day part to work?

As far I can tell, yes. The native KNIME date type requires a day.

2 Likes

darn, you may be right! I just managed to build this to get a Jan-2020 to 01-2020!

now I only have to figure how to avoid this with a String Manipulation (multi column) node, having all those missing values. I joined the string 01- to the columns aaaaaand now this:

Alright. My final solution would be using a dictionary table:

1 Like

Got another one I want to share:
I played with the Regex Extractor to see how my MMM-yyyy is presented in RegEx code.
Then with a String Manipulation (multi column) I wrote this in order to append a prefix of “01-” to the original string (e.g. “Jan-2015”):

regexReplace($$CURRENTCOLUMN$$, “[a-zA-Z0-9-]{8}”, string(join(“01-”, $$CURRENTCOLUMN$$)))

It containt 8 symbols, and I want to match it in order to exclude the missing cell from replacing (i.e. empty would become “01-”).
So after this operation - adding a day to my mm-yyyy string, a String to Date&Time does the job of recognizing the dd-MMM-yyyy as a date and converting it.

Cheers!

3 Likes