@Maciejg, thanks for your last reply. I was once told that it's not common for topic starters to answer their topics that way, that's why.
The code I use now is:
let $referenceDate := xs:date("2024-01-01")
let $daysInWeek := 7
let $startDate := fn:current-date()
let $endDate := xs:date($temp.t_laatsteLeverDatum) (: or $temp.t_dateRequestedJDE :)
return if (
fn:sum(
for $i in 0 to fn:days-from-duration($endDate - $startDate)
let $currentDate := $startDate + xs:dayTimeDuration(concat('P', $i, 'D'))
let $daysSinceReference := fn:days-from-duration($currentDate - $referenceDate)
let $dayOfWeek := (1 + ($daysSinceReference mod $daysInWeek)) (: Convert to 1=Monday, ..., 7=Sunday :)
return if ($dayOfWeek >= 1 and $dayOfWeek <= 5) then 1 else 0
) <= 3
) then 1 else 0
This code gave the expected 9 instead of 5. Unfortunately the simpler function fn:day-of-week() was not available in the environment I am working in.
Thanks for thinking along and your reactions and kind regards,
Aad