Create & Extract Months in the Past 12 Months

Hi,

So I have a task to create a column containing month number in the past 12 months (from current execution date). But I find some difficulties to find the right node and maybe some logic behind it to create this list of months.

Maybe you can help me to solve this problem. Thanks in advance!

Hi @Kemuel , these 2 nodes will do:
image

Results:
image

Here are the instructions:
You just need to configure the Create Date&Time Range as follows:

  1. Set the type to Date
  2. Set number of rows to 12
  3. Starting point, choose “Use execution date&time” which will use the current date
  4. Set Interval to “-1M” meaning -1 Month per row

Then just extract the month number using the Extract Date&Time Fields, like this:

EDIT: Not sure which order you wanted it. If you are satisfied with the order above, then it’s all good.
But if you want it in the reverse order, you can add a Sorter node at the end, like this:
image

And sort on the Date column that was generated, in Ascending order:
image

The result will be in the reverse order of the above:
image

7 Likes

Hi,

Sorry for the late reply Bruno. Thanks a lot for your help, it really answer my question.

1 Like

No problem @Kemuel , happy to help!

1 Like

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