Error in string output to Columns

 _SECTION_BEGIN("Parameter");
FilterParam=ParamStr("Thu/Fri","Fri");
FilterDate =ParamStr("mmdd/mmddyy","mmdd");
FilterSheet = ParamStr("Average/Expiry","Average");
_SECTION_END();

 _SECTION_BEGIN("Last Thursday");
function Lastthursday()
{
 Daysinmonth=IIf(Month()==1 OR Month()==3 OR Month()==5 OR Month()==7 OR Month()==8 OR Month()==10 OR Month()==12,31,30);
 Daysinmonthfeb=IIf(Year()%4 == 0 AND Year()%100!=0,29,28);
 Daysinmonthfinal=IIf(Month()==2,Daysinmonthfeb,Daysinmonth);
 returnvalue=IIf(Daysinmonthfinal-Day()<7 AND DayOfWeek()==4,1,0);
 return returnvalue;
}
 _SECTION_END();

 
 barssinceexpiry=BarsSince(Lastthursday());
 barssinceexpiry=IIf(Lastthursday(),1,barssinceexpiry);
 barssinceexpirynum = LastValue(barssinceexpiry);
 
 
 if(FilterParam=="Thu")
    { 
        LastF = LastThursday();
     }
else if  (FilterParam=="Fri")    
 { 
      LastF = Ref(LastThursday(),-1);
 }
 
 Scrip=Name();
 ScripF1=Scrip+"-I";
 ScripF2=Scrip+"-II";
 
FOClose=Foreign(ScripF1,"C");
FOATP=Foreign(ScripF1,"1");
FOOI=Foreign(ScripF1,"I");
FOVal = FOOI *FOATP/10000000;  

FNClose=Foreign(ScripF2,"C");
FNATP=Foreign(ScripF2,"1");
FNOI=Foreign(ScripF2,"I");
FNVal = FNOI *FNATP/10000000;  
 
function DateNumToStr(nDate) 
{
string = StrFormat("%7.07g", nDate);

yy = StrLeft(string, 3);
mm = StrMid(string, 3, 2);
dd = StrRight(string, 2);

yy = StrToNum(yy) + 1900; 

/*if(FilterDate=="mm/dd")
    { 
       return dd + "/" + mm ;
     }
else if(FilterDate=="mm/dd/yy")   
     { 
      return dd + "/" + mm+ "/" + NumToStr(yy, 1, False);
     }
*/

//Only mm & dd
return dd + "/" + mm ;
//Full Date
//return dd + "/" + mm+ "/" + NumToStr(yy, 1, False);
}

C1 = ValueWhen(LastF,C,1);
C2 = ValueWhen(LastF,C,2);
C3 = ValueWhen(LastF,C,3);
C4 = ValueWhen(LastF,C,4);
C5 = ValueWhen(LastF,C,5);
C6 = ValueWhen(LastF,C,6);
C7 = ValueWhen(LastF,C,7);
C8 = ValueWhen(LastF,C,8);
C9 = ValueWhen(LastF,C,9);
C10= ValueWhen(LastF,C,10);
C11= ValueWhen(LastF,C,11);
C12= ValueWhen(LastF,C,12);
C13= ValueWhen(LastF,C,13);
 
OI1 = ValueWhen(LastF,FOOI,1);
OI2 = ValueWhen(LastF,FOOI,2);
OI3 = ValueWhen(LastF,FOOI,3);
OI4 = ValueWhen(LastF,FOOI,4);
OI5 = ValueWhen(LastF,FOOI,5);
OI6 = ValueWhen(LastF,FOOI,6);
OI7 = ValueWhen(LastF,FOOI,7);
OI8 = ValueWhen(LastF,FOOI,8);
OI9 = ValueWhen(LastF,FOOI,9);
OI10= ValueWhen(LastF,FOOI,10);
OI11= ValueWhen(LastF,FOOI,11);
OI12= ValueWhen(LastF,FOOI,12);
OI13= ValueWhen(LastF,FOOI,13);
OI14= ValueWhen(LastF,FOOI,14);


OIDiff1 = OI1 - OI2;
OIROC1 = OIDiff1 / OI2 *100;
OIDiff2 = OI2 - OI3;
OIROC2 = OIDiff2 / OI3 *100;
OIDiff3 = OI3 - OI4;
OIROC3 = OIDiff3 / OI4 *100;
OIDiff4 = OI4 - OI5;
OIROC4 = OIDiff4 / OI5 *100;
OIDiff5 = OI5 - OI6;
OIROC5 = OIDiff5 / OI6 *100;
OIDiff6 = OI6 - OI7;
OIROC6 = OIDiff6 / OI7 *100;
OIDiff7 = OI7 - OI8;
OIROC7 = OIDiff7 / OI8 *100;
OIDiff8 = OI8 - OI9;
OIROC8 = OIDiff8 / OI9 *100;
OIDiff9 = OI9 - OI10;
OIROC9 = OIDiff9 / OI10 *100;
OIDiff10 = OI10 - OI11;
OIROC10 = OIDiff10 / OI11 *100;
OIDiff11 = OI11 - OI12;
OIROC11 = OIDiff11 / OI12 *100;
OIDiff12 = OI12 - OI13;
OIROC12 = OIDiff12 / OI13 *100;
OIDiff13 = OI13 - OI14;
OIROC13 = OIDiff13 / OI14 *100;


Date1 = ValueWhen(LastF,DateNum(),1);
Date1Str = DateNumToStr(Date1);
Date2 = ValueWhen(LastF,DateNum(),2);
Date2Str = DateNumToStr(Date2);
Date3 = ValueWhen(LastF,DateNum(),3);
Date3Str = DateNumToStr(Date3);
Date4 = ValueWhen(LastF,DateNum(),4);
Date4Str = DateNumToStr(Date4);
Date5 = ValueWhen(LastF,DateNum(),5);
Date5Str = DateNumToStr(Date5);
Date6 = ValueWhen(LastF,DateNum(),6);
Date6Str = DateNumToStr(Date6);
Date7 = ValueWhen(LastF,DateNum(),7);
Date7Str = DateNumToStr(Date7);
Date8 = ValueWhen(LastF,DateNum(),8);
Date8Str = DateNumToStr(Date8);
Date9 = ValueWhen(LastF,DateNum(),9);
Date9Str = DateNumToStr(Date9);
Date10 = ValueWhen(LastF,DateNum(),10);
Date10Str = DateNumToStr(Date10);
Date11 = ValueWhen(LastF,DateNum(),11);
Date11Str = DateNumToStr(Date11);
Date12 = ValueWhen(LastF,DateNum(),12);
Date12Str = DateNumToStr(Date12);
Date13 = ValueWhen(LastF,DateNum(),13);
Date13Str = DateNumToStr(Date13);
 
 
 Filter =1;
 
if(FilterSheet=="Average")
    {
     
    AddColumn(OI1,"OI-"+Date1Str,1.0);
	AddColumn(OI2,"OI-"+Date2Str,1.0);
	AddColumn(OI3,"OI-"+Date3Str,1.0);
	AddColumn(OI4,"OI-"+Date4Str,1.0);
	AddColumn(OI5,"OI-"+Date5Str,1.0);
	AddColumn(OI6,"OI-"+Date6Str,1.0);
	AddColumn(OI7,"OI-"+Date7Str,1.0);
	AddColumn(OI8,"OI-"+Date8Str,1.0);
	AddColumn(OI9,"OI-"+Date9Str,1.0);
	AddColumn(OI10,"OI-"+Date10Str,1.0);
	AddColumn(OI11,"OI-"+Date11Str,1.0);
	AddColumn(OI12,"OI-"+Date12Str,1.0);
	AddColumn(OI13,"OI-"+Date13Str,1.0);
	SetSortColumns(1);

    }
else if  (FilterSheet=="Expiry")    
    { 
    
    AddColumn(OI1,"OI-"+Date1Str,1.0);
	AddColumn(OIROC1,Date1Str+"-"+Date2Str,1.2);
    AddColumn(OI2,"OI-"+Date2Str,1.0);
	AddColumn(OIROC2,Date2Str+"-"+Date3Str,1.2);
	AddColumn(OI3,"OI-"+Date3Str,1.0);
	AddColumn(OIROC3,Date3Str+"-"+Date4Str,1.2);
	AddColumn(OI4,"OI-"+Date4Str,1.0);
	AddColumn(OIROC4,Date4Str+"-"+Date5Str,1.2);
	AddColumn(OI5,"OI-"+Date5Str,1.0);
	AddColumn(OIROC5,Date5Str+"-"+Date6Str,1.2);
	AddColumn(OI6,"OI-"+Date6Str,1.0);
	AddColumn(OIROC6,Date6Str+"-"+Date7Str,1.2);
	AddColumn(OI7,"OI-"+Date7Str,1.0);
	AddColumn(OIROC7,Date7Str+"-"+Date8Str,1.2);
	AddColumn(OI8,"OI-"+Date8Str,1.0);
	AddColumn(OIROC8,Date8Str+"-"+Date9Str,1.2);
	AddColumn(OI9,"OI-"+Date9Str,1.0);
	AddColumn(OIROC9,Date9Str+"-"+Date10Str,1.2);
	AddColumn(OI10,"OI-"+Date10Str,1.0);
	AddColumn(OIROC10,Date10Str+"-"+Date11Str,1.2);
	AddColumn(OI11,"OI-"+Date11Str,1.0);
	AddColumn(OIROC11,Date11Str+"-"+Date12Str,1.2);
	AddColumn(OI12,"OI-"+Date12Str,1.0);
	AddColumn(OIROC12,Date12Str+"-"+Date13Str,1.2);
	AddColumn(OI13,"OI-"+Date13Str,1.0);  
	SetSortColumns(1); 
    } 


/*AddColumn(C1,"C-"+Date1Str,1.0);
AddColumn(C2,"C-"+Date2Str,1.0);
AddColumn(C3,"C-"+Date3Str,1.0);
AddColumn(C4,"C-"+Date4Str,1.0);
AddColumn(C5,"C-"+Date5Str,1.0);
AddColumn(C6,"C-"+Date6Str,1.0);
AddColumn(C7,"C-"+Date7Str,1.0);
AddColumn(C8,"C-"+Date8Str,1.0);
AddColumn(C9,"C-"+Date9Str,1.0);
AddColumn(C10,"C-"+Date10Str,1.0);
AddColumn(C11,"C-"+Date11Str,1.0);
AddColumn(C12,"C-"+Date12Str,1.0);
AddColumn(C13,"C-"+Date13Str,1.0);*/

Column%20Name

The error seems to be coming through on the dates

it's likely to get this result , if one or more stock does not generate the signal of " Lastf " condition , try to apply the formula to lonely one stock which you are sure that it generate true signal for "lastf" , then you will probably get the expected result

It's indeed because one of the symbols got relisted recently as a different entity. Subject to corporate actions, such happenings would certainly be repeated in the future. So what would be the round about?
On the calculation front, there is no error as it keeps the corresponding entries blank, so the issue lies only with the string output. Can we have something like getting the dates for just 1 of the symbols and pass it on as string?