awk '
BEGIN {for (n=split ("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC", T); n>0; n--) M[T[n]] = n
FS=","
}
{split ($9, T, "-")
printf "<tag1>%s</tag1>\n<date>20%02d-%02d-%02d</date>\n", $1, T[3], M[T[2]], T[1]
}
' file
<tag1>AAA</tag1>
<date>2005-05-01</date>
<tag1>BBB</tag1>
<date>2005-05-10</date>
Welcome to forums, please use code tags as per forum rules. For your problem there are following things which I am considering and providing this code.
i- Your month names will be JAN FEB MAR APR MAY JUN JULY AUG SEPT OCT NOV DEC style always into your Input_file.(Else you could have change it according to your requirement too.)
ii- Output which you have shown to us as <tag1>BBBB</tag1> , where BBBB is a typo. As I could see only BBB into shown input.
Following may help you in same.
awk -F, '{split($NF, array,"-");num=split("JAN FEB MAR APR MAY JUN JULY AUG SEPT OCT NOV DEC", months," ");for(i=1;i<=num;i++){if(months==array[2]){Q=sprintf("%02d", i)}};print "<tag1>" $1 "</tag1>" ORS "<date>" "20" array[3] "-" Q "-" array[1] "</date>"}' Input_file
awk -F, '
{split ($9, T, "-")
printf "<tag1>%s</tag1>\n<date>20%02d-%02d-%02d</date>\n", $1, T[3], (index ("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC", T[2]) + 3) / 4, T[1]
}
' file