My organization's accounting calendar varies from a standard monthly calendar as shown below. I am trying to determine a method of calculating the number of NETWORKDAYS within a project task span that falls within each month's corresponding accounting calendar span. It is simple enough if the entire project task falls between the accounting month dates. However, I cannot find a way to calculate the number of NETWORKDAYS when the project span overlaps and extends into different accounting months. See the table below. Non-working days are weekends and Independence Day (7/4/22) in the example below. I have manually calculated the number of NETWORKDAYS and filled in these days in the highlighted green areas. The number of NETWORKDAYS is 15, with 12 falling within the July accounting period of 6/27/22 - 7/24/22 and 3 within the August accounting period of 7/25/22 - 8/28/22.
I need to determine the correct formula(s) to automatically calculate and populate the denoted monthly cells with the number of NETWORKDAYS for the project task within the proper accounting month, including a value of 0 when applicable (0 for June in this case).