How do I iterate through a loop and also query the same table

gnewuser
Tera Contributor

Hi, I have a table  A and I query all the reocrds and I have 2 fields in the table that I need to get for example "numberofdays1" and "numberofdays2".

 

Once I get that I add the "numberofdays1" and "numberofdays2". But once I get this "totalnumberofdays", I need to query the same table A and find a field called  "Enddate"(which is a date field) and add the following condition:

 

get all records where the "Enddate" is within the  "totalnumberofdays" .

 

Now I am confused as to how do I code this.

 

 

var grA = new GlideRecord("A");
grA.Query(); 

var totalnumberofdays;

while (grA .next()){
 
totalnumberofdays= grA .numberofdays1+ grA .numberofdays1;
}

Now inside this loop, how do I query the same table "A", and find all the records where the "Enddate" is within a "totalnumberfdays"