How are we identifying the year ? Please clarify the same with example.
Yes i have written the code in i_step = 1 because as per your initial post you never told us about user input variable and moreover if you need just the last date of previous month based on current month then that code will suffice your requirement.
In case that is dependent on user entry then we need to change the logic accordingly and write the code in i_step = 2.
Regards,
AL