How to get the first day of the previous month using Python? Using datetime from datetime import date d = date(2019, 1, 8) # date.today() month, year = (d.month-1, d.year) if d.month != 1 else (12, d.year-1) last_month = d.replace(day=1, month=month, year=year) print(last_month) # 2018-12-01 Using datetime and timedelta from datetime import date from datetime import timedelta d = date(2019, 1, 8) # date.today() last_month = (d - timedelta(days=d.day)).replace(day=1) print(last_month) # 2018-12-01 Using dateutil from datetime import date from dateutil.relativedelta import relativedelta d = date(2019, 1, 8) # date.today() last_month = d.replace(day=1) - relativedelta(months=1) print(last_month) # 2018-12-01 Using arrow import arrow d = arrow.get(2019, 1, 8) # arrow.now() last_month = d.shift(months=-1).replace(day=1).datetime.date() print(last_month) # 2018-12-01