Python Get First Date of Last Month Example
This article goes in detailed on python get last month first day. We will use python get last month date. We will use python get first date of previous month. this example will help you how to get last month first date in python.
In this example, I will give you a simple example of getting the first date of last month using datetime and relativedelta. so let's see a simple example with output.
You can use these examples with python3 (Python 3) version.
import datetime from dateutil import relativedelta today = datetime.date.today() # Getting Last Month First Date lastMonthDate = today - relativedelta.relativedelta(months=1, day=1) print(lastMonthDate);
I hope it can help you...
We are Recommending you
- Python Create Zip Archive from Directory Example
- How to Check if Today is Wednesday or not in Python?
- Python Check if Date is Weekend or Weekday Example
- Python PATCH Request with Parameters Example
- Python GET Request with Parameters Example
- How to Subtract Months to Date in Python?
- How to Get Tomorrow Date in Python?
- How to Get Current Minute in Python?
- How to Get Current Hour in Python?
- How to Get Current Month in Python?
- How to Get Current Year in Python?