In [1]: from datetime import datetime In [2]: import dateutil.relativedelta In [3]: today_date = datetime.now().date() In [4]: today_date Out[1]: datetime.date(2016, 7, 5) In [5]: last_month = today_date - dateutil.relativedelta.relativedelta(months=1) In [6]: last_mont_first_date = last_month.replace(day=1) In [7]: last_mont_first_date Out[2]: datetime.date(2016, 6, 1)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter