Skip to main content
June 29, 2021
Solved

Skip months within specific months range within given interval

  • June 29, 2021
  • 3 replies
  • 0 views

Excercise is to have below output -

02/06/2021

02/08/2021

02/10/2021

02/12/2021

Startdate 02/06/2021

Enddate   20/12/2021

Noofintervals 2 months

any idea to achieve this?

    Best answer by csteward

    Try this out for size.  The edate() function is useful for adding straight months.

    a!localVariables(
      local!startDate: date(2021,06,02),
      local!endDate: date(2021,12,20),
      local!monthIntervals: 2,
      local!monthsBetween: month(local!endDate)-month(local!startDate)+12*(year(local!endDate)-year(local!startDate)),
      {
        local!startDate,
        reject(
          rule!APN_isEmpty,
          a!forEach(
            items: 1+enumerate(local!monthsBetween),
            expression: if(
              mod(fv!index,local!monthIntervals)=0,
              edate(local!startDate,fv!item),
              null
            )
          )
        )
      }
    )

    3 replies

    csteward
    cstewardAnswer
    June 29, 2021

    Try this out for size.  The edate() function is useful for adding straight months.

    a!localVariables(
      local!startDate: date(2021,06,02),
      local!endDate: date(2021,12,20),
      local!monthIntervals: 2,
      local!monthsBetween: month(local!endDate)-month(local!startDate)+12*(year(local!endDate)-year(local!startDate)),
      {
        local!startDate,
        reject(
          rule!APN_isEmpty,
          a!forEach(
            items: 1+enumerate(local!monthsBetween),
            expression: if(
              mod(fv!index,local!monthIntervals)=0,
              edate(local!startDate,fv!item),
              null
            )
          )
        )
      }
    )

    June 30, 2021

    Hi Chris.. this code worked for me as expected, thanks for your time and great help.