Need Help with Code

I have a FromDate - ToDate.

I trying to loop through the date range and exclude Saturday and Sunday (0 and 6).

I can’t get the getDay() function to work when I loop through the dates.

Here is the Sample of the Code: Please let me know if you can get it to work.

Server Side JavaScript:

var FromDate=currentDocument.getItemValueDate(“FromDate”);

var ToDate=currentDocument.getItemValueDate(“ToDate”);

var IncrementDate = FromDate;

if(ToDate!=null){

while (IncrementDate <= ToDate){

DayVal=IncrementDate.getDay();

if (DayVal!=0 && DayVal!=6)

{

//Add the Date to the List

}

IncrementDate.adjustDay(1);

}}

Subject: Got it Working

I had to replace “DayVal=IncrementDate.getDay();” with "DayVal= @Adjust(IncrementDate,0,0,1,0,0,0);