This is my code:
global theDataGridArrayNames
global theDataGridArray
global counterP
put 1 into i
put false into isFinished
put the date into dateToday
convert dateToday to system date
put dateToday into dateTodaySeconds
convert dateTodaySeconds to seconds
put 1 into indexP
repeat while i <= counterP and isFinished is not true
put the word 2 of theDataGridArray[theDataGridArrayNames[8]["name"]] into nDays
put theDataGridArray[theDataGridArrayNames[3]["name"]] into tDate
convert tDate from system date to dateItems
add nDays to item 3 of tDate
convert tDate from dateItems to system date
put tDate into tDateSeconds
convert tDateSeconds from system date to seconds
if tDateSeconds <= dateTodaySeconds then
put theDataGridArray[theDataGridArrayNames[1]["name"]] into tdataUsers[indexP]
add 1 to indexP
put empty into tDate
else
end if
if i < counterP then
add 1 to i
else
put true into isFinished
end if
end repeat
I Will try your code and i will tell you...

regards,
fko