Extract work days only from data range

Certified Associate Developer

Hello, 

I would like how to formulate string which can be foreached after with only working dates between two dates. 

Lets say if I have 

start date: 2021-02-15 19:11:43

end date: 2021-02-22 19:11:43

In this case the result have to be {2021-02-15, 2021-02-16, 2021-02-17, 2021-02-18, 2021-02-19, 2021-02-22}

Any ideas how this can be achieved ?

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    As usual, a!forEach() saves the day...

    a!localVariables(
      
      local!date1: today(),
      local!date2: today() + 8,  /* these 2 are hardcoded just for example sake */
      
      local!dateSpan: tointeger(local!date2 - local!date1), /* get the number of days difference between the 2 dates (8) */
      
      a!forEach(
        items: enumerate(local!dateSpan+1), /* get a list of {0 ... N} where N = the total number of days */
        
        expression: local!date1 + fv!item /* start date + 0, start date + 1, ... start date + N */
      )
    )

Reply
  • +1
    Certified Lead Developer

    As usual, a!forEach() saves the day...

    a!localVariables(
      
      local!date1: today(),
      local!date2: today() + 8,  /* these 2 are hardcoded just for example sake */
      
      local!dateSpan: tointeger(local!date2 - local!date1), /* get the number of days difference between the 2 dates (8) */
      
      a!forEach(
        items: enumerate(local!dateSpan+1), /* get a list of {0 ... N} where N = the total number of days */
        
        expression: local!date1 + fv!item /* start date + 0, start date + 1, ... start date + N */
      )
    )

Children