My code works fine as a single array custom function but when I try to run
Arrayformula(if A2:A = true, nextyear(A2:A),nextmonth(A2:A)
It doesn't work, it says internal error.
From what I've seen looks like it could be because my function is taking too long?
function NextMonth(input) {
if(input.map) {
return input.map(NextMonth);}
else {
var month = Utilities.formatDate(new Date(input), "GMT+0","MM")-1;
var day = Utilities.formatDate(new Date(input), "GMT+0","dd");
var year = Utilities.formatDate(new Date(input), "GMT+0","yyyy");
var output = new Date(year,month,day,0,0,0,0);
var now = new Date();
while (output < new Date()) {
var month = Utilities.formatDate(new Date(output), "GMT+0","MM")-1+1;
var day = Utilities.formatDate(new Date(output), "GMT+0","dd");
var year = Utilities.formatDate(new Date(output), "GMT+0","yyyy");
var output = new Date(year,month,day,0,0,0,0);
}
return (output)
}
}