Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Adding 3 Workdays to a Date

Please Help, I have worked on this for some time and can't seem to find a solution online.  I am needing to add 3 Workdays to an Application date. The application date can be any day of the year, b...
  • mahoneypat's avatar
    mahoneypat
    5 years ago

    Since counting in PQ starts at 0, you need to subtract 1 from the working days to get correct value from the list of working days.

     

    Here is the function version, updated with that.

     

     

    (startdate as date, workingdays as number) =>
    let
    Source = List.Select(
    List.Dates( // make a list of dates
    startdate,
    workingdays + 1 + Number.RoundUp(workingdays / 5, 0) * 2, // go out far enough to include due date in working days
    #duration(1, 0, 0, 0)
    ),
    each List.Contains({1..5}, Date.DayOfWeek(_)) // keep just dates that are Monday through Friday
    ){workingdays - 1} // get the needed value from the list you've created
    in
    Source
     
    Pat