import datetime from dateutil.relativedelta import relativedelta last_year = (datetime.datetime.now()-relativedelta(years=1)).strftime("%Y-%m-%d")