DEV Community

Dutra
Dutra

Posted on

SAS Function isBrHolidayworkingDaysBetweenDates

The function returns the number of working days between two given dates.

proc fcmp outlib=work.sas_functions.dateFunctions;

    /*
    =================== 
     * FUNCTION:workingDaysBetweenDates
     * AUTHOR: Dutra - dutra@relevants.org
     * DESCRIPTION: Returns the number of working days 
     between two given dates
    ===================
    */
    function workingDaysBetweenDates(startDate, endDate);
        numberDays = 0;
        addData = startDate;

        if startDate <= endDate then;
        do while (addData <= endDate);
            if isBusinessDay(addData) <> 0 then
                numberDays = numberDays + 1;
            addData = intnx('day',addData,1);
        end;

        return(numberDays);
    endsub;

quit;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)