Business/Working days in AX

Business/Working days in AX

MCP · Azure DevOpsYour delivery board, readable by an agentMCP · DataverseOne consent, and the data layer opensMCP · Dynamics 365 F&OConnecting F&O to an agent Microsoft hasn’t documented
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.

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));

}
Previous article← Stop deletion of record from a table
Discussion

Ask a question or leave feedback

This is a review interaction. The WordPress version will store, thread and moderate comments.

Thanks — submitted for moderation in this review.
Search the whole site · Ctrl/⌘ + K