<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Select range of rows around user input start date in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47992#M27314</link>
    <description>&lt;P&gt;Datetimes are in units of seconds, so you'll to do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;set_min = (set_date - (1 * 365 * 24 * 3600));
set_max = (set_date + (1 * 365 * 24 * 3600));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 30 Nov 2017 20:55:56 GMT</pubDate>
    <dc:creator>pmroz</dc:creator>
    <dc:date>2017-11-30T20:55:56Z</dc:date>
    <item>
      <title>Select range of rows around user input start date</title>
      <link>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47991#M27313</link>
      <description>&lt;P&gt;I am working with a large data set spanning many years, which can be simplified to&amp;nbsp;two columns named&amp;nbsp;"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&amp;nbsp;the Test_date specified by the user, and then delete all other rows from the data table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is what I have tried so far. I&amp;nbsp;have created the upper and lower date limits for a input ID, but am&amp;nbsp;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; current data table();
dt &amp;lt;&amp;lt; new column("T_YEAR", numeric, continuous, set each value(:Test_date / (365*86400)));

setpoint =  ;//user specified numeric value
set_row= dt &amp;lt;&amp;lt; get rows where(:ID == setpoint);

set_date = dt:T_YEAR[set_row] ;
set_min = (set_date - 1);
set_max = (set_date + 1);


dt &amp;lt;&amp;lt; select where(:T_YEAR &amp;gt;= set_min &amp;amp; :T_YEAR &amp;lt;= set_max )
   &amp;lt;&amp;lt; invert row selection
   &amp;lt;&amp;lt; delete rows;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Nov 2017 21:04:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47991#M27313</guid>
      <dc:creator>ben_T</dc:creator>
      <dc:date>2017-11-30T21:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Select range of rows around user input start date</title>
      <link>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47992#M27314</link>
      <description>&lt;P&gt;Datetimes are in units of seconds, so you'll to do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;set_min = (set_date - (1 * 365 * 24 * 3600));
set_max = (set_date + (1 * 365 * 24 * 3600));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Nov 2017 20:55:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47992#M27314</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-11-30T20:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select range of rows around user input start date</title>
      <link>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47994#M27315</link>
      <description>&lt;P&gt;Yes, that's essentially what I did by creating a new column "T_YEAR"&amp;nbsp;with the date converted to years using Test_date/ (365*86400). I've tried both, and it works either way. The issue seems to occur when using set_min and set_max variables in&amp;nbsp;select where() to find all rows between those values.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2017 21:04:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47994#M27315</guid>
      <dc:creator>ben_T</dc:creator>
      <dc:date>2017-11-30T21:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select range of rows around user input start date</title>
      <link>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47995#M27316</link>
      <description>&lt;P&gt;Lots of ways to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the &lt;A href="http://www.jmp.com/support/help/13-2/Date_Time_Functions.shtml#123215" target="_self"&gt;In Years()&lt;/A&gt; function to return the JMP datetime value for a number of years, or the &lt;A href="http://www.jmp.com/support/help/13-2/Date_Time_Functions.shtml#194976" target="_self"&gt;Date Increment()&lt;/A&gt; function to add or subtract a number of years.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you could get the &lt;A href="http://www.jmp.com/support/help/13-2/Date_Time_Functions.shtml#123298" target="_self"&gt;Year()&lt;/A&gt; of your set&amp;nbsp;date, add 1 to that and use the &lt;A href="http://www.jmp.com/support/help/13-2/Date_Time_Functions.shtml#123217" target="_self"&gt;Date MDY()&lt;/A&gt; function to give you the JMP date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;set_min = (set_date - In Years(1));
set_max = (set_date + In Years(1));

//or

set_min = Date Increment(set_date, "Year", -1, "actual");
set_max = Date Increment(set_date, "Year", 1, "actual");

//or

set_min = Date MDY( Month( set_date ), Day( set_date ), Year( set_date ) - 1 );
set_max = Date MDY( Month( set_date ), Day( set_date ), Year( set_date ) + 1 );


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2017 21:23:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47995#M27316</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2017-11-30T21:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select range of rows around user input start date</title>
      <link>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47997#M27317</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/9769"&gt;@ben_T&lt;/a&gt;, it looks like your reply and mine overlapped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=open("$SAMPLE_DATA\TechStock.jmp");

set_date=datemdy(12, 15, 2000);

set_min = (set_date - In Days(5));
set_max = (set_date + In Days(5));


dt &amp;lt;&amp;lt; select where(:Date &amp;gt;= set_min &amp;amp; :Date &amp;lt;= set_max )
   &amp;lt;&amp;lt; invert row selection
   &amp;lt;&amp;lt; delete rows;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that I had to change to In Days() instead of years only because the sample data didn't have more than one year in it, but other than that this should work for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2017 21:35:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-range-of-rows-around-user-input-start-date/m-p/47997#M27317</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2017-11-30T21:35:16Z</dc:date>
    </item>
  </channel>
</rss>

