Getting calendar for past 3 years from current month/year.

I need something like this below:

Product name Date
KK Jan-19
KK Feb-19
KK Mar-19
KK Apr-19
KK May-19
KK Jun-19
KK Jul-19
KK Aug-19
KK Sep-19
KK Oct-19
KK Nov-19
KK Dec-19
KK Jan-20
KK Feb-20
KK Mar-20
KK Apr-20
KK May-20
KK Jun-20
KK Jul-20
BB Jan-19
BB Feb-19
BB Mar-19
BB Apr-19
BB May-19
BB Jun-19
BB Jul-19
BB Aug-19
BB Sep-19
BB Oct-19
BB Nov-19
BB Dec-19
BB Jan-20
BB Feb-20
BB Mar-20
BB Apr-20
BB May-20
BB Jun-20
BB Jul-20

I have the unique project names with me. I am not being able to create a range of past 3 years from today in month/year format. I am looking for a flow which will help me create a range of dates in month/year format.

Sri

Hi @Bunny1990 and welcome to the KNIME forum,

You can use the Create Date&Time Range node. If you select a 3 years span and enter 36 as the fixed number of the rows you will get the monthly dates. You can manipulate the date values to have exactly what you want. If you want the dates to be dynamic and determined regarding the execution date of the workflow, you can select “use execution date&time” for End date and a variable for the start date.
For the start date variable, you can use another create date&time range node to create 1 row with current execution date value and then use the Date&Time Shift to have the start date.

:blush:

4 Likes

Thanks a lot @armingrudd. I did get the start and end dates with the 2 nodes. After that, which node will help me in creating the range of month/year between these 2 dates? I see that I cannot send an input to Create Date&Time Range node.

1 Like

Here is an example:

25424-1-1.knwf (25.2 KB)

:blush:

3 Likes

Hi @Bunny1990 and @armingrudd,

this can also be achieved with less nodes. The Create Date&Time Range node allows to set a negative interval (-1M in this case).
Btw, the Cross Joiner allows you to easily combine the months with your product names.

See this workflow: https://kni.me/w/ngcN9RSViEma3yTx (12.9 KB)
image

Best,
Simon

3 Likes

Thanks a lot. It worked super fine. Really appreciate such a quick reply @armingrudd.

:blush:

1 Like

Thanks a lot for this as well. I was struggling more with the dynamic creation of date range. I wanted both the months and the start date as a flow variable.

Attached my solution. @SimonS and @armingrudd

Date Range creation.knwf (40.7 KB)

:blush:

Thanks
Srikant

3 Likes

Oh, I missed the interval option! (how?!!) :face_with_head_bandage:

Thank you @SimonS

:blush:

Dear @Bunny1990,

If you need to start from the first month, you can shift to -3y, manipulate the month and then pass the date as variable to use it as the start date with 1M interval.

25424-1-2.knwf (26.5 KB)

Currently, your workflow is not generating all months: 2018-2 is missing.

:blush:

Oh Yeah :upside_down_face:
Thanks for poinitng it out
:slight_smile:

1 Like