I am working with a large data set spanning many years, which can be simplified to two columns named "ID" and "Test_date" . Date is formatted as 'm/d/y', and the data table is sorted chronologically. I would like to select all of the rows where the test date is within one year (before or after) of the Test_date specified by the user, and then delete all other rows from the data table.
Below is what I have tried so far. I have created the upper and lower date limits for a input ID, but am unable to select the dates within that range using select where(). Instead, I get the error "The argument to SelectWhere did not evaluate to true or false, it is [0]... ". Any help on this would be much appreciated.
dt << current data table();
dt << new column("T_YEAR", numeric, continuous, set each value(:Test_date / (365*86400)));
setpoint = ;//user specified numeric value
set_row= dt << get rows where(:ID == setpoint);
set_date = dt:T_YEAR[set_row] ;
set_min = (set_date - 1);
set_max = (set_date + 1);
dt << select where(:T_YEAR >= set_min & :T_YEAR <= set_max )
<< invert row selection
<< delete rows;