Date format

Hi all,
I’m quit new to knime and would like to create a new column with the date of the current month in the following format:
i.g. September = “09/2021”.

Can you help me with the code?

Thanks a lot :slight_smile:

Markus

Hi @Markus3003,

I created an example workflows that demonstrates how you can do this:

best,
Gabriel

3 Likes

Hi @Markus3003 , first of all, just to clarify, you need the current month and also the current year, correct?

This can be done as follows:
image

First, I get the current date. After that, I extract the month and year using the Extract Date&Time Fields. Then I simply concatenate the month and year in the format you showed.

Results:
image

Alternatively, you could use use substr() to extract the month and year based on the position, however, depending on your locale setting, dates are formatted differently. That is why using the Extract Date&Time Fields is more precise (100% precise) as Knime will check this setting to do the proper extraction of the fields.

Here’s the workflow: Get current month and year.knwf (9.1 KB)

3 Likes

Hi Bruno,

yes correct, the current month and year.
Thank you ver much for your solution. I think that will work.

Best
Markus

The solution works, thanks a lot @gab1one

1 Like

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