/****************************************************************************************************************************************** * SubRoutine = MinAndMax - Identify the Min and Max Times of the Field within a Table * @example code * CALL MinAndMax('$(vPathTo)','$(vTable)','$(vField)'); ******************************************************************************************************************************************/ SUB MinAndMax(vPathTo, vTable, vField) LET vQvd = '$(vTable)' & '.qvd'; $(vTable): Load [$(vField)] FROM [$(vPathTo)$(vQvd)] (QVD); //Create a table with the earliest and latest dates from our source data MinTable: LOAD MIN([$(vField)]) AS MinDate RESIDENT $(vTable); //Create a table with the earliest and latest dates from our source data MaxTable: LOAD MAX([$(vField)]) AS MaxDate RESIDENT $(vTable); DROP TABLE $(vTable); // No longer need the distinct date values table. /* --> 0 denotes the first record. --> 1 the second, and so on. --> Negative numbers indicate order from the end of the table. --> -1 denotes the last record read. */ Set vRecord = -1; LET v_MinDate = Num(floor(Peek('MinDate', $(vRecord), 'MinTable'))); //create a variable that peeks into our new table to pull in min date - dropping any timestamp data. LET v_MinTime = Num(Peek('MinDate', $(vRecord), 'MinTable')); //create a variable that peeks into our new table to pull in min date - dropping any timestamp data. LET v_MaxDate = Num(floor(Peek('MaxDate', $(vRecord), 'MaxTable'))); //create a variable that peeks into our new table to pull in max date - dropping any timestamp data. LET v_MaxTime = Num(Peek('MaxDate', $(vRecord), 'MaxTable')); //create a variable that peeks into our new table to pull in max date - dropping any timestamp data. DROP TABLES MinTable, MaxTable; //Don't need the interim MinMax table any longer now that the min and max dates are stored in variables. LET vRecord = NULL(); LET vQvd = NULL(); LET vPathTo = NULL(); LET vTable = NULL(); LET vField = NULL(); END SUB