python datetime last day of month
>>import calendar
>>year, month = 2016, 12
>>calendar.monthrange(year, month)[1]
31
python datetime last day of month
>>import calendar
>>year, month = 2016, 12
>>calendar.monthrange(year, month)[1]
31
python find end of month
import calendar
from datetime import datetime
year = 2020
month = 1
rng = calendar.monthrange(year, month) # (2, 31)
last_day = datetime(year, month, rng[1])
# calendar.monthrange returns tuple in the format of
# (<day of week>, <last day>). day of week is 0 indexed
# starting on Monday
#
# 0 = Monday
# 1 = Tuesday
# 2 = Wednesday
# 3 = Thursday
# 4 = Friday
# 5 = Saturday
# 6 = Sunday
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us