I have the following three formulas, I am trying to accomplish the following with them. The Names array is holding dates pulled from the Db, I want the DB record associated with the date that is closest to todays date. I am getting the date difference in seconds between these two dates and placing these values in another array. Then I am bubble sorting the array of data differences to get the smallest one in the first position. Once I have this done, I grab the Name element that has the same index as the smallest value of the date difference array. Is my syntax correct? Will these formulas return the correct data? Thanks in advance.
Group Header:
WhilePrintingRecords;
Global DateVar array Names;
"";
Details Section:
WhilePrintingRecords;
Global DateVar array Names;
NumberVar i := 1;
Redim Preserve Names[UBound(Names) + 1];
Names[UBound(Names)] := Date({Timeline.TransitionDate});
Group Footer:
Global DateVar array Names;
NumberVar array buffer;
NumberVar temp;
NumberVar i := 1;
NumberVar k := 1;
NumberVar j := 1;
NumberVar p := 1;
for i := 1 to UBound (Names) step 1 do
Redim Preserve buffer[UBound(buffer) + 1];
buffer[UBound(buffer)] := (DateDiff ("s",DateTime(Names) , CurrentDate ));
;
for k := 1 to UBound (buffer) step 1 do
if(k <> UBound(buffer)) then
for j := k+1 to UBound (buffer) step 1 do
if(buffer[k] > buffer[j]) then
temp := buffer[k];
buffer[k] := buffer[j];
buffer[j] := temp;
;
for p := 0 to UBound(Names) step 1 do
if(buffer[1] = (DateDiff ("s",DateTime(Names[p]) , CurrentDate ))) then
Names[p];
Group Header:
WhilePrintingRecords;
Global DateVar array Names;
"";
Details Section:
WhilePrintingRecords;
Global DateVar array Names;
NumberVar i := 1;
Redim Preserve Names[UBound(Names) + 1];
Names[UBound(Names)] := Date({Timeline.TransitionDate});
Group Footer:
Global DateVar array Names;
NumberVar array buffer;
NumberVar temp;
NumberVar i := 1;
NumberVar k := 1;
NumberVar j := 1;
NumberVar p := 1;
for i := 1 to UBound (Names) step 1 do
Redim Preserve buffer[UBound(buffer) + 1];
buffer[UBound(buffer)] := (DateDiff ("s",DateTime(Names) , CurrentDate ));
;
for k := 1 to UBound (buffer) step 1 do
if(k <> UBound(buffer)) then
for j := k+1 to UBound (buffer) step 1 do
if(buffer[k] > buffer[j]) then
temp := buffer[k];
buffer[k] := buffer[j];
buffer[j] := temp;
;
for p := 0 to UBound(Names) step 1 do
if(buffer[1] = (DateDiff ("s",DateTime(Names[p]) , CurrentDate ))) then
Names[p];