Karan Parekh
Karan's blog

Follow

Karan's blog

Follow
Fetch the last day of the month in Python

Photo by Towfiqu barbhuiya on Unsplash

Fetch the last day of the month in Python

Karan Parekh's photo
Karan Parekh
·Jul 11, 2022·

1 min read

Play this article

Python does not have a simple method to fetch the last day of the month. Instead, you need to use the monthrange() method from the calendar module as shown here. Not an inconvenience really.. 🤷‍♂️

>>> import calendar
>>> calendar.monthrange(2022, 2)[1]
28

Thanks for reading :)

 
Share this