PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WB19] - Can't seem to filter records in "For Each" loop
[WB19] - Can't seem to filter records in "For Each" loop
Iniciado por guest, 12,jul. 2016 19:31 - 2 respuestas
Publicado el 12,julio 2016 - 19:31
Hi - this statement doesn't restrict records to records that 6 months old or later, it berings back records that are years old too - what am I doing wrong?

gpgdEventStartDate = Today()
gpgdEventStartDate..Month -= 6

FOR EACH gpsdEvents WHERE "bDeleted = 0 AND dStartDate > ' "+gpgdEventStartDate+" ' "

//code to populate table goes here

END
Publicado el 17,julio 2016 - 23:49
Hi Did you ran through it with the debeugger?

Go step by step through the code . And See if the values are what you expect them to be.

if gpgdEventStartDate..Month -= 6 doesnot give the right date then then the rest goes worng.

I think , just a guess that this is where the fault lies but use the debugger and see for yourself

gpgdEventStartDate..Month = gpgdEventStartDate..Month -6 is something you can try


regards
Allard
Publicado el 18,julio 2016 - 00:03
Hi Joel,

Are you using M$sql or MySQL or HFCS?

If using SQL, I would create the sql to generate all of the records e.g

gpgdEventStartDate = Today()

convert gpgdEventStartDate

sql ="select * from XXX_file where bDeleted = 0 AND dStartDate > "+gpgdEventStartDate
res=HExecuteQuery(QueryName, hQueryDefault, sql)
if res true
while not

// code

read next
end

This will give you all the records as per for criteria.
it will loop through until all records processed.

This is from memory late at night so may need a little tweeking!!

Regards,