# Integration Toolkit Solutions Wiki

**URL:** <https://forum.inductiveautomation.com/t/integration-toolkit-solutions-wiki/105080>\
**Category:** 3rd Party Modules\
**Tags:** scripting, ignition81\
**Created:** [April 14, 2025, 9:02pm UTC](https://forum.inductiveautomation.com/t/integration-toolkit-solutions-wiki/105080 "2025-04-14T21:02:36Z")\
**Posts on this page:** 1\
**Showing post:** 24

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 13, 2025, 12:23pm UTC](https://forum.inductiveautomation.com/t/integration-toolkit-solutions-wiki/105080/24 "2025-10-13T12:23:39Z")

</div>

# Creating a list of Months in format `YYYY-MM` between a start and end date

Note: `forEach(10, it())` is equivalent to `range(10)` in Python.

Expression Structure Binding:

```python
start: 2025-06-01 0:00:00
end: 2025-10-01 00:00:00

```

```python
forEach(
	forEach(monthsBetween({value}['start'], {value}['end'])+1, it()),
	dateFormat(addMonths({value}['start'], it()), 'yyyy-MM')
)

```

Returns:

```python
[
  "2025-06",
  "2025-07",
  "2025-08",
  "2025-09",
   "2025-10"
]

```

One of the `forEach()` loops is unneeded. `forEach()` returns a list, so your outer loop is actually `forEach(asList(0,1,2,3,4),it())`

```python
forEach(
    monthsBetween({value}['start'],{value['end']) + 1,
    dateFormat(addMonths({value}['start'],it()),'yyyy-MM')
)

```

Will yeild the same result.

> **Features employed**
>
> - [Iterables](https://www.automation-pros.com/toolkit/doc/iteration.html#iterables) General behavior of all iterators.
> - [`forEach()`](https://www.automation-pros.com/toolkit/doc/iteration.html#foreach) Loops through the dataset, calling the nested expression with one row at a time.
> - [`it()`](https://www.automation-pros.com/toolkit/doc/iteration.html#it) Delivers the one row in dataset format (same column names and types as the source).
> - [`monthsBetween()`](https://docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/date-and-time/Between) Calculates the number of whole months between two dates.
> - [`addMonths()`](https://docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/date-and-time/add) Add or subtract an amount of months to a given date and time.
> - [`dateFormat()`](https://docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/date-and-time/dateFormat) Returns the given date as a string, formatted according to a pattern.

_Pssst!_ Use `yyyy-MM` to avoid year-end confusion over week-years.

---

_[View the full topic](https://forum.inductiveautomation.com/t/integration-toolkit-solutions-wiki/105080)._
