I am trying to convert a month represented by a number to a written month name, for example going from 9
to September
. I have three sequential Set Variable modules:
Variable 1 - previousMonthNumber
Uses the built-in date functions to take the current date, add -1 months to get the previous month, and formats it to just be the number month value:
{{formatDate(addMonths(now; -1); "M")}}
Resulting variable value is: 9
Variable 2 - monthsArr
Uses the built-in array functions to create a blank array, and populate it with the written months:
{{add(emptyarray; "January"; "February"; "March"; "April"; "May"; "June"; "July"; "August"; "September"; "October"; "November"; "December")}}
Resulting variable value is: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
Variable 3 - previousMonthRead
Should use the previous two variables to get the previous month as a written word. I thought it would be quite simple to do this using array indexing, as I would were I coding. I tried this:
However, the output of the above is:
"previousMonthRead": "January, February, March, April, May, June, July, August, September, October, November, December[9]"
I have tried varying syntax changes such as monthsArr.previousMonthNumber
, but nothing seems to work and the result is always some variation of the full array with the previousMonthNumber just added onto the end of it.
So, my question is, if not with standard indexing syntax, how do I do array indexing within the variable value definition box? I feel like I must be missing something really obvious because I thought this would be very simple to do.
Iād be grateful for any help!