XQuery/Net Working Days

Motivation
To calculate the "effective" age of many documents you want to count the number of working days they have been in various stages. This means you count the weekdays but not the weekend days. You can even discard the holidays if you want to have consistent aging reports.

Approach
Since NetWorkingDays is a calculation that is shared by many systems, it makes sense to use a XQuery module to put the logic into.

The heart of this calculation is a NetWorkingDays algorithm that is passed two dates.

Sample Test Driver
Back to Unit Testing Main Menu Back to CRV Main Menu

Discussion
The recursive function works but it is slow. It has to call itself once for each date between the two dates. An alternative approach is to count the end days in each fraction of a week, count the weeks and multiply by five.

Code??

Acknowledgments
An initial version of this was provided by Chris Wallace.