To calculate the “efficient” age of many paperwork you need to depend the variety of working days they’ve been in varied phases. This implies you depend the weekdays however not the weekend days. You possibly can even discard the vacations if you wish to have constant growing old experiences.


Since NetWorkingDays is a calculation that’s shared by many methods, it is smart to make use of a XQuery module to place the logic into.

module namespace fxx = "";

declare perform fxx:net-working-days-n($s as xs:date, $f as xs:date, $dates as xs:date*, $complete as xs:integer) as xs:integer {
    if ($s= $f)
    then $complete
    else if (fxx:weekday($s) and never($s = $dates))
             then fxx:net-working-days-n($s + xs:dayTimeDuration('P1D'), $f, $dates,$complete + 1)
             else fxx:net-working-days-n($s + xs:dayTimeDuration('P1D'), $f, $dates,$complete )

declare perform fxx:net-working-days($s as xs:date, $f as xs:date) as xs:integer {

(:  this perform returns one lower than the quantity returned from Excel NETWORKDAY :
    networkdays($d,$d) ought to be Zero however it's 1.
    networkdays and workday ought to be inverses and they aren't
    widespread observe appears to be to subtract one anyway.
  (:  assumes  $s <= $f :)
    fxx:net-working-days-n($s,$f, (), 0)


declare perform fxx:net-working-days($s as xs:date,$f as xs:date, $dates as xs:date*) as xs:integer {
    fxx:net-working-days-n($s,$f, $dates, 0)


The center of this calculation is a NetWorkingDays algorithm that’s handed two dates.

Pattern Check Driver[edit]

xquery model "1.0";

import module namespace fxx = "" at "net-working-days.xq";

(: Check driver for Web Working Days
 : tags to generate documentation utilizing scripts at
 : @return XHTML desk for subsequent "caldays" days from now together with working days calculations from at this time
 : @input-parameter: caldays - an integer variety of calendar days sooner or later from now
let $cal-days := xs:integer(request:get-parameter("caldays", "30"))

let $now := xs:date(substring(current-date(),1,10))


Days from {$now}

Immediately is a {fxx:day-of-week-name-en(xs:date(substring(current-date(),1,10)))}

Format: net-working-days.xq?cal-days=50

border="1"> Cal Days Future Date Day of Week Web Working Days { for $i in (Zero to $cal-days) let $d := $now + xs:dayTimeDuration(concat('P',$i,'D')) let $dow := fxx:day-of-week($d) return align="heart">{$i} align="heart">{$d} align="heart">{fxx:day-of-week-name-en(xs:date(substring($d,1,10)))} align="heart">{fxx:net-working-days(xs:date(substring(current-date(),1,10)),$d)} }
href="index.xhtml">Again to Unit Testing Fundamental Menu
href="../../index.xhtml">Again to CRV Fundamental Menu


The recursive perform works however it’s sluggish. It has to name itself as soon as for every date between the 2 dates. An alternate method is to depend the tip days in every fraction of every week, depend the weeks and multiply by 5.



An preliminary model of this was offered by Chris Wallace.

Leave a Reply

Your email address will not be published. Required fields are marked *