Data is not correct in output when change to 2021 in pandas dataframe

I am trying to get data for previous year and present year from dataframe using below function.

def get_date(s_year, s_month):
‘’‘Function to get date from year and month
Arg:
(s_year, s_month as <string, int>)
Returns:
date as datetime.date’’’
dt = pd.to_datetime(int(s_year)*10000+int(s_month)*100+1, format = “%Y%m%d”)
return dt.date()

def get_last_day(idt):
‘’‘Function to get the last date of a month
Arg:
idt as date
Returns:
last date as datetime.date
‘’’
dt = pd.to_datetime(idt) + pd.tseries.offsets.MonthEnd(1)
return dt.date()

It is working fine for 2019, 2020 and 2021. but when i changed to 2020 and 2021 and 2022 it is not giving output.

Do i need to change something in function,
Please share your valuable suggestion

Thanks a ton

Please format your code as code, as described in About the Users category, and please copy and paste the exact function calls your tried and the output you got. It is impossible for anybody to understand why something is going wrong without seeing what is going wrong.

That being said, that’s a rather odd way to create a date object. You could just use the standard datetime.date constructor.