Skip to main content

Command Palette

Search for a command to run...

Fetch the last day of the month in Python

Published
1 min read
Fetch the last day of the month in Python
K

I am a developer sharing the problems I solve through my blog. Just giving back to the community I learned so much from! Have an amazing day :)

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 :)