I'd call through to a Python interpreter for this. Adopting the accepted answer from Using Python to count the number of business days in a month? --
countBusinessDaysPy=$(cat <<'EOF'
import datetime, sys
businessdays = 0
startDate = datetime.date.fromisoformat(sys.argv[1])
endDate = datetime.date.fromisoformat(sys.argv[2])
if endDate < startDate:
(startDate, endDate) = (endDate, startDate)
while startDate <= endDate: # change from <= to < to not count both start and end days
if startDate.weekday() < 5:
businessdays += 1
startDate += datetime.timedelta(days=1)
print(businessdays)
EOF
)
countBusinessDays() { python3 -c "$countBusinessDaysPy" "$@"; }
...gives you a shell function that calls a Python interpreter to do the math you need (note that this is an inclusive range). Thereafter:
$ countBusinessDays 2019-01-01 2020-01-01
262
$ countBusinessDays 2019-01-01 2019-01-07
5
Calling this looping over your file (note that in the real world, I'd do the looping in Python, not in bash) might look like:
{
read -r header; printf '%s
' "$header,TotalDates"
while IFS=, read -r resolved startOfWork rest; do
printf '%s
' "${resolved},${startOfWork}${rest:+,$rest},$(countBusinessDays "$startOfWork" "$resolved")"
done
} <yourInputFile
...which emits as output:
Resolved,StartOfWork,TotalDates
2020-01-16,2020-01-10,5
2020-01-13,2020-01-13,1
2020-01-20,2020-01-15,4
2020-01-20,2020-01-14,5
2020-01-14,2020-01-09,4
2020-01-09,2020-01-08,2
2020-01-16,2020-01-14,3
2020-01-09,2020-01-07,3
2020-01-14,2020-01-12,2