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 lastmonth
from datetime import date, timedelta
last_day_of_prev_month = date.today().replace(day=1) - timedelta(days=1)
start_day_of_prev_month = date.today().replace(day=1) - timedelta(days=last_day_of_prev_month.day)
# For printing results
print("First day of prev month:", start_day_of_prev_month)
print("Last day of prev month:", last_day_of_prev_month)
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