Can either of your fields be null? If it can, you need to modify your code to something like this (I haven't tested it...)
local NumberVar bkglth;
local NumberVar i := 0;
shared datetimevar array aDate;
if not IsNull({Table.StartDate}) and not IsNull({table.EndDate}) then
bkglth := := DateDiff('d',{Table.Start Date},{Table.End Date});
Redim aDate[bkglth];
For i:= 0 to bkglth do
(
aDate:= dateadd("m",i,{Table.Start Date});
);
else <figure out what to do if the dates are null....>
-Dell