Dear Forum,

I have written a function that has a bad performance. I use it in an edict but It takes to long to run and sometimes causes Tinderbox to crash when exporting the document. It also seriously slows down or blocks the execution of stamps.

Goal of the function is to calculate the number of working days (excl weekendday’s saturday and sunday).

When starting Tinderbox the function takes about 13 minutes to run over 346 notes. This repeats every hour or so when the edict runs again. Apparently I did something wrong or maybe such a function is not workable in Tinderbox.

The function is as follows:

```
function fDoorloopTijd() {
var:date vStart = $DatumIn.format("D-M0-y");
var:date vEnd = $DatumUit.format("D-M0-y");
var:date vLoopDate = vStart.format("D-M0-y");
var:num vDagen = days(vStart,vEnd);
var:list vSetDagen=;
var:num vDoorloop=;
vLoopDate = date(vLoopDate + "1 day"); //Dag van ontvangst telt niet mee
vEnd = date(vEnd + "1 day"); //Dag van versturen telt wel mee
// de routine maakt een lijst van de dagen vanaf start tot en met eind
while(vLoopDate.format("D-M0-y")!=vEnd.format("D-M0-y")){
vSetDagen+=vLoopDate.weekday+";";
vLoopDate = date(vLoopDate + "1 day");
};
// De doorlooptijd wordt berekend op het aanfal weekdagen
$Doorlooptijd = vSetDagen.count_if(anItem,anItem<6); //Weekend dagen tellen niet mee
};
```

Is there a way to improve this function?

Many thanks in advance for your help.

Jan