I am trying to get the date of the previous month with python. Here is what i\'ve tried:
str( time.strftime(\'%Y\') ) + str( int(time.strftime(\'%m\'))-1 ) <
def prev_month(date=datetime.datetime.today()): if date.month == 1: return date.replace(month=12,year=date.year-1) else: try: return date.replace(month=date.month-1) except ValueError: return prev_month(date=date.replace(day=date.day-1))