Print mondays between given dates

Hi,

How can we print dates on mondays between the given start date and end date?

Please provide the code for it.

For Example:

Input:

Start Date: 24/May/2021

End Date: 25 June/2021

output:

            31/May/2021 

            07/June/2021   

            14/June/2021

             21/June/2021

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    The above solution posted by Ranjith would work except I don't find the function "getDatesBetweenDate" anywhere - perhaps it's in a plug-in that I'm not familiar with.

    The following OOB code might be slightly more flexible and uses a!forEach instead of the index/whereContains combo, which can be a bit easier to read at least.

    a!localVariables(
      local!numDays: tointeger(ri!enddate - ri!startDate) + 1,
      local!dates: a!forEach(
        enumerate(local!numDays),
        ri!startDate + fv!item
      ),
      
      a!flatten(
        a!forEach(
          local!dates,
          if(
            text(fv!item, "dddd") <> "Monday",
            {},
            a!map(
              date: fv!item,
              day: text(fv!item, "dddd")
            )
          )
        )
      )
    )

Reply
  • 0
    Certified Lead Developer

    The above solution posted by Ranjith would work except I don't find the function "getDatesBetweenDate" anywhere - perhaps it's in a plug-in that I'm not familiar with.

    The following OOB code might be slightly more flexible and uses a!forEach instead of the index/whereContains combo, which can be a bit easier to read at least.

    a!localVariables(
      local!numDays: tointeger(ri!enddate - ri!startDate) + 1,
      local!dates: a!forEach(
        enumerate(local!numDays),
        ri!startDate + fv!item
      ),
      
      a!flatten(
        a!forEach(
          local!dates,
          if(
            text(fv!item, "dddd") <> "Monday",
            {},
            a!map(
              date: fv!item,
              day: text(fv!item, "dddd")
            )
          )
        )
      )
    )

Children
No Data