Following job is to calculate business days/working days in AX using base calendars.
In my case base calendar name is "24/5" you can change it as per your setup.
In my case base calendar name is "24/5" you can change it as per your setup.
static void
businessdaysInPeriod(Args _args)
{
WorkCalendarSched workCalendarSched;
date start;
date end;
counter
workingdays;
counter
totaldays;
CalendarId primCalendar="24/5";
;
start = str2date("21-11-2014",123);
end = str2Date("26-11-2015",123);
workCalendarSched = new
workCalendarSched();
while(start<=end)
{
totaldays++;
if(workCalendarSched.isdateopen(primCalendar,start)==true)
{
workingdays++;
}
start++;
}
info(strfmt("Total
days: : %1",totaldays));
info(strfmt("Total
working days: : %1",workingdays));
}
Hi Faisal can i use this to find the total working days between Delivery date and Start date of a sales order, For a report?
ReplyDeleteThis post helped me find the base AX method. It should probably be used:
ReplyDeleteinfo(strFmt("%1", WorkCalendarCalculator::calcDuration(start, end, primCalendar)));