Want to get 2nd Wednesday for the month and year I have given

Hi everyone,

I have a use case where a due date will be the 2nd Wednesday of the next month of given month and year. 

  Discussion posts and replies are publicly visible

Parents
  • Here is a quick method by looping to find the second Wednesday of next month:

    a!localVariables(
      local!targetMonth: if(ri!month=12,1,ri!month+1),
      local!targetYear: if(ri!month=12,ri!year+1,ri!year),
      local!targetDay: index(
        reject(
          a!isNullOrEmpty,
          a!forEach(
            items: 1+enumerate(daysinmonth(local!targetMonth,local!targetYear)),
            expression: if(weekday(date(local!targetYear,local!targetMonth,fv!item),1)=4,fv!item,null)
          )
        ),
        2,
        null
      ),
      
      date(local!targetYear,local!targetMonth,local!targetDay)
    )

Reply
  • Here is a quick method by looping to find the second Wednesday of next month:

    a!localVariables(
      local!targetMonth: if(ri!month=12,1,ri!month+1),
      local!targetYear: if(ri!month=12,ri!year+1,ri!year),
      local!targetDay: index(
        reject(
          a!isNullOrEmpty,
          a!forEach(
            items: 1+enumerate(daysinmonth(local!targetMonth,local!targetYear)),
            expression: if(weekday(date(local!targetYear,local!targetMonth,fv!item),1)=4,fv!item,null)
          )
        ),
        2,
        null
      ),
      
      date(local!targetYear,local!targetMonth,local!targetDay)
    )

Children
No Data