Tuesday, 19 January 2021

Python Function - Find the Next Business Days After n Days | Maximo

You have 15 business days (exclude weekends) to complete the task, what will be the 15thday?


from java.util import Calendar

#Function definition
def getNextBusinessDday(dn ):
    cal = Calendar.getInstance();
    cal.setTime(d)
    loop=1
    while(loop<=n) :
        cal.add(cal.DATE, +1)
        if (cal.get(cal.DAY_OF_WEEK)) not in [cal.FRIDAY,cal.SATURDAY] : 
            loop=loop+1
        vserial = loop
    calculatedetc = cal.getTime()
    return calculatedetc

#variables for input
d = mbo.getDate("changedate")
n = 15

#function call whereever you want in the same script
getNextBusinessDday(d,n)

No comments:

Post a Comment