Answers for "the month before python dateime"

1

the month before python dateime

import datetime
 today = datetime.date.today()
 first = today.replace(day=1)
 lastMonth = first - datetime.timedelta(days=1)
 print(lastMonth.strftime("%Y%m"))
Posted by: Guest on May-05-2021

Code answers related to "the month before python dateime"

Python Answers by Framework

Browse Popular Code Answers by Language