Workdays Calculation

Workdays Calculation

Hi everyone,

I've created a function to calculate the number of workdays between two dates.
I use it to measure how many weekdays have passed since a record in our action log was opened.

Previously, I was using the function suggested here
But this function is recursive and after a record was open more than around 50 days, the stack limit would be reached.

Have a look at my new function below. 
The only limitation I can see is that any holidays are not taken into account.
What do you think?

  1. int Diff_Calc(date startDate)
  2. {
  3.     today = zoho.currentdate;
  4.     totDiff = days360(input.startDate,today);
  5.     diffDiff = (floor((totDiff  /  7))  *  2);
  6.     actualDiff = (totDiff  -  diffDiff);
  7.     startDayofWeek = input.startDate.getDayOfWeek();
  8.     endDayofWeek = today.getDayOfWeek();
  9.     if (startDayofWeek  >  endDayofWeek)
  10.     {
  11.         Correction = -1;
  12.     }
  13.     else if ((startDayofWeek  ==  1)  &&  (endDayofWeek  ==  7))
  14.     {
  15.         Correction = 0;
  16.     }
  17.     else if ((startDayofWeek  ==  1)  ||  (endDayofWeek  ==  7))
  18.     {
  19.         Correction = -1;
  20.     }
  21.     else
  22.     {
  23.         Correction = 1;
  24.     }
  25.     correctDiff = (actualDiff  +  Correction);
  26.     return correctDiff;
  27. }