(year, month, day)
return res.date()
For a given month get the business day of the month
    that falls on or before the passed in day
For a given month get the business day of the month
    that falls on or before the passed in day
For a given month get the business day of the month that falls on or before the passed in day
def get_business_day_of_month_before(year, month, day):
    """
    For a given month get the business day of the month
    that falls on or before the passed in day
    """
    try:
        adate = datetime.datetime(year, month, day)
    except ValueError:
        try:
            adate = datetime.datetime(year, month, 30)
        except ValueError:
            try:
                adate = datetime.datetime(year, month, 29)
            except ValueError:
                adate = datetime.datetime(year, month, 28)
    r = rrule.rrule(
        rrule.MONTHLY, byweekday=(rrule.MO, rrule.TU, rrule.WE, rrule.TH, rrule.FR),
        dtstart=datetime.datetime(year, month, 1))
    res = r.before(adate, inc=True)
    if (res is None or res.month != month or res.year != year):
        raise ValueError("No dates found in range. is there a flaw in your logic?")
    return res.date()
def get_business_day_of_month_before ( year , month , day ) : try : adate = datetime . datetime ( year , month , day ) except ValueError : try : adate = datetime . datetime ( year , month , 30 ) except ValueError : try : adate = datetime . datetime ( year , month , 29 ) except ValueError : adate = datetime . datetime ( year , month , 28 ) r = rrule . rrule ( rrule . MONTHLY , byweekday = ( rrule . MO , rrule . TU , rrule . WE , rrule . TH , rrule . FR ) , dtstart = datetime . datetime ( year , month , 1 ) ) res = r . before ( adate , inc = True ) if ( res is None or res . month != month or res . year != year ) : raise ValueError ( "No dates found in range. is there a flaw in your logic?" ) return res . date ( )