Setting the number of days values in a month

Hi

There is one agent which sets the number of days in a month that falls between a date range. This doesnot include saturdays and sundays.

Please help me if I can deduct the extra declared dates in a view too based on the location. This would mean that number of days will not include saturdays , sundays and extra declared dates.

Existing Code :

daysinMonth1:=0;daysinMonth2:=0;daysinMonth3:=0;daysinMonth4:=0;daysinMonth5:=0;daysinMonth6:=0;daysinMonth7:=0;daysinMonth8:=0;daysinMonth9:=0;daysinMonth10:=0;daysinMonth11:=0;daysinMonth12:=0;

totalDays:=0;

FIELD To_Lwp:=To_Lwp;

frm:=@Date(from);

To1:=@If(Leavetype_1=“LWP”;To_noLwp;To);

@While(@Date(frm) <= @Date(To1);

@If(@Weekday(frm) != 7 & @Weekday(frm) != 1;@Do(

@If(@Month(frm)=1;daysinMonth1:=@ToNumber(daysinMonth1)+1;

	   @Month(frm)=2;daysinMonth2:=@ToNumber(daysinMonth2)+1;

	   @Month(frm)=3;daysinMonth3:=@ToNumber(daysinMonth3)+1;

	   @Month(frm)=4;daysinMonth4:=@ToNumber(daysinMonth4)+1;

	   @Month(frm)=5;daysinMonth5:=@ToNumber(daysinMonth5)+1;

	   @Month(frm)=6;daysinMonth6:=@ToNumber(daysinMonth6)+1;

        @Month(frm)=7;daysinMonth7:=@ToNumber(daysinMonth7)+1;

	   @Month(frm)=8;daysinMonth8:=@ToNumber(daysinMonth8)+1;

	   @Month(frm)=9;daysinMonth9:=@ToNumber(daysinMonth9)+1;

	   @Month(frm)=10;daysinMonth10:=@ToNumber(daysinMonth10)+1;

	   @Month(frm)=11;daysinMonth11:=@ToNumber(daysinMonth11)+1;

	   @Month(frm)=12;daysinMonth12:=@ToNumber(daysinMonth12)+1;

""));"");

frm:=@Adjust(@Date(frm);0;0;1;0;0;0));

 REM { Unique ID};

  y:=@DbLookup("":"Nocache";@DbName;"COM";StaffName;3);

  n:=@If(@IsError(y);"";y);

REM { Leave availed from masters in the month of April};

      April:=@GetDocField(n;"apr");

      Tot_April:=@ToNumber(April)+@ToNumber(daysinMonth4);

      @SetDocField(n;"apr";Tot_April);

REM { Leave availed from masters in the month of May};

      May:=@GetDocField(n;"may");

      Tot_May:=@ToNumber(May)+@ToNumber(daysinMonth5);

      @SetDocField(n;"may";Tot_May);

Thanks in Advance

Subject: Setting the number of days values in a month

Not exactly sure what you want to do but it sounds like you should take a look at the function @BusinessDays.