Get First Date of Last Month in Python
Sep 19, 2022
Hi Dev,
In this quick example, let's see Get First Date of Last Month in Python. This tutorial will give you simple example of Get Last Month Date in Python. We will use Get Previous Month First Date in Python. Here you will learn 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.
so let's see following examples with output:
Example
main.py
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);
Output:
2022-08-01
- Get Last 2 Digits of Number in Python Tutorial Example
- How to Sum of First and Last Digit of Number in Python?
- How to Get First and Last Digit of Number in Python?
- Get the Last Digit of Number in Python Tutorial Example
- Get the First Digit of Number in Python Tutorial Example
- How to Remove All Decimals from Number in Python?
- How to Convert String to Float with 2 Decimal Places in Python?
- How to Format Number to 2 Decimal Places in Python?