Integration Toolkit Solutions Wiki

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:

start: 2025-06-01 0:00:00
end: 2025-10-01 00:00:00
forEach(
	forEach(monthsBetween({value}['start'], {value}['end'])+1, it()),
	dateFormat(addMonths({value}['start'], it()), 'YYYY-MM')
)

Returns:

[
  "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())

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

Will yeild the same result.

Features employed
  • Iterables General behavior of all iterators.
  • forEach() Loops through the dataset, calling the nested expression with one row at a time.
  • it() Delivers the one row in dataset format (same column names and types as the source).
  • monthsBetween() Calculates the number of whole months between two dates.
  • addMonths() Add or subtract an amount of months to a given 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.

4 Likes