Calculate businessdays

Hi, i’m new at this but i’ve been given a task to calculate salary for the starting month of an employee. The problem is, the employee might not start at the beginning of the month so i must calculate the salary from the startdate of his/her work til the enddate of the month.

I’ve got a startdate field (user input) , enddate , proposed salary (user input) , totalsalary, base(the total days in a month), and workdays(total days of employee’s working days)

The problem is, i don’t know how to extract the month from the startdate field so that i can adjust the enddate to become the end of the “startdate” month. N as i’m new at this, i’m not sure which is more suitable, using the @formula language or the Lotusscript.

N lets say i have the month of the startdate already, how am i supposed calculate total number of businessdays of the “startdate” month? so far i’ve only done this :-

xx=Evaluate({@BusinessDays(Istartdate; enddate; 1:7)}, doc)

doc.workdays=xx

but the enddate field’s formula is computed using this month’s enddate so it’s

mth :=@Month(@Now)+1;

@Adjust ( @Date( year ; mth ; 1); 0 ; 0 ; -1 ; 0 ; 0 ; 0)

The question is, what if i’m calculating a salary of an employee who started last month? The computer will calculate the whole of this month and last month so it’ll return a wrong answer. Any tips or suggestions would be very much appreciated. Thanks in advance.

Subject: Calculate businessdays

Try something like this:

This formula will calculate the number or working (week) days between any two dates.

StartDate is the early date and EndDate is the ending date (obviously). This will not take any holiday/vacation days into account. You could add extra code to access a holiday schedule and add that into the calculation.

diffDays := (EndDate - StartDate) / 86400;

strtDay := @Modulo(@Weekday(StartDate); 7);

endDay := @Modulo(@Weekday(EndDate); 7);

weekdays := (diffDays - endDay + strtDay - 7) * 5 / 7 - @Max(-2; -strtDay) - @Min(1; endDay) + 5 - strtDay + endDay

Subject: Calculate businessdays

startdate := @TextToTime(“12/04/2006”);offsetstartday := 0 - @Day(startdate);

nextmonth := @Adjust(startDate; 0;1;0;0;0;0);

LastDayOfStartMonth := @Adjust(nextmonth; 0;0;offsetstartday;0;0;0);

busdays := @BusinessDays(startdate; LastDayOfStartMonth; 1:7);

@Prompt([Ok]; “business days”; @Text(busdays))