Not sure I understand. You seem to want to run a script for several selectable months back from a certain date.
Why do you define that 12 element array? Why the loop? Where do you pass the date parameter?
Did you search these fora for similar if not idential problems and solutions? I'm pretty sure that kind of problem has been solved umpteen times before.
But what is your problem? Eyeballing your script suggests to me that it should work the way you intend it to. Your original post boils down to "I want to do this and have written this script to do it". A statement and no questions.
Sorry for confusing guys. Actually as i said i am having a main script where date and number of months will be passed fo e.g..
sh main_script.sh 2017-12-10 12<YYYY-MM-DD>
Inside the main script i would be calling a subscript called test.sh which has date as input parameter. Based on my inputs from main_script parameter i need to run the internal script for 12 months back starting from 2016-12-10 till 2017-12-10 by passing each dates to test.sh
sh test.sh 2016-09-27
sh test.sh 2016-10-27