[WB19] - Can't seem to filter records in "For Each" loop

Startbeitrag von Joel am 12.07.2016 17: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

Antworten:

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

von Allard - am 17.07.2016 21:49
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,

von cardcoder - am 17.07.2016 22:03
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.