<?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 Find time difference between rows in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837540#M101394</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working on setting up a script. One of the steps is for us to determine if the 'Timestamp' is within 30 minutes of the row above or below, with them in sequential order by UCN. Obviously, I need this to include the date and time. Below is the script/formula I am using. But when I do it, it is only looking at times and not taking into account the UCN or the date. You can see in my '30 minutes' column that it is not identifying right.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is set up so that the UCNs are those within 5 digits of each other. But then I need it to determine if those UCN's have a timestamp within 30 minutes of the ones that are within the 5 digits. Hopefully that makes sense. So if you look at rows 12 and 13, it says they are a match based on the timestamp, but they are not because they have different center codes and the UCNs are not 5 digits apart. Row 11 and 12 are within 5 digits for the UCN, but the time is more than 30 minutes apart, so it should not be identifying as a '1'/red in the 'time within 30' column.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// New column: Time within 30
Data Table("Time within 30 minutes") &amp;lt;&amp;lt; New Column("Time within 30",
	Numeric,
	"Continuous",
	Format("Best", 12),
	Formula(
		If(
			Dif(Num(:Unit Entry Timestamp), 1) &amp;lt;= 30 | Abs(Dif(Num(:Unit Entry Timestamp), -1))
			 &amp;lt;= 30,
			1,
			0
		)
	)
) &amp;lt;&amp;lt; Move Selected Columns({:Time within 30}, after(:Positive or Negative));
 
// Change column info: Time within 30
Data Table("Time within 30 minutes"):Time within 30 &amp;lt;&amp;lt;
Set Property("Value Colors", {0 = 2, 1 = 3}) &amp;lt;&amp;lt; Color Cell by Value(1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;</description>
    <pubDate>Fri, 07 Feb 2025 15:54:11 GMT</pubDate>
    <dc:creator>patriciafm811</dc:creator>
    <dc:date>2025-02-07T15:54:11Z</dc:date>
    <item>
      <title>Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837540#M101394</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working on setting up a script. One of the steps is for us to determine if the 'Timestamp' is within 30 minutes of the row above or below, with them in sequential order by UCN. Obviously, I need this to include the date and time. Below is the script/formula I am using. But when I do it, it is only looking at times and not taking into account the UCN or the date. You can see in my '30 minutes' column that it is not identifying right.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is set up so that the UCNs are those within 5 digits of each other. But then I need it to determine if those UCN's have a timestamp within 30 minutes of the ones that are within the 5 digits. Hopefully that makes sense. So if you look at rows 12 and 13, it says they are a match based on the timestamp, but they are not because they have different center codes and the UCNs are not 5 digits apart. Row 11 and 12 are within 5 digits for the UCN, but the time is more than 30 minutes apart, so it should not be identifying as a '1'/red in the 'time within 30' column.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// New column: Time within 30
Data Table("Time within 30 minutes") &amp;lt;&amp;lt; New Column("Time within 30",
	Numeric,
	"Continuous",
	Format("Best", 12),
	Formula(
		If(
			Dif(Num(:Unit Entry Timestamp), 1) &amp;lt;= 30 | Abs(Dif(Num(:Unit Entry Timestamp), -1))
			 &amp;lt;= 30,
			1,
			0
		)
	)
) &amp;lt;&amp;lt; Move Selected Columns({:Time within 30}, after(:Positive or Negative));
 
// Change column info: Time within 30
Data Table("Time within 30 minutes"):Time within 30 &amp;lt;&amp;lt;
Set Property("Value Colors", {0 = 2, 1 = 3}) &amp;lt;&amp;lt; Color Cell by Value(1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 07 Feb 2025 15:54:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837540#M101394</guid>
      <dc:creator>patriciafm811</dc:creator>
      <dc:date>2025-02-07T15:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837693#M101397</link>
      <description>&lt;P&gt;&lt;STRIKE&gt;Create new column in which you combine date and time (date + time) and then&lt;/STRIKE&gt; fix your Pos UCN to numeric if they are numbers. Then you should be able to use similar idea you have for your time comparison to Pos UCN &lt;STRIKE&gt;and to the new timestamp column.&lt;/STRIKE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 16:10:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837693#M101397</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-07T16:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837722#M101401</link>
      <description>&lt;P&gt;Also remember to comparisons in seconds as that is how JMP handles time. You can for example use In Minutes(30) to convert 30minutes into seconds (or just use 30*6)&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 16:28:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837722#M101401</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-07T16:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837734#M101404</link>
      <description>&lt;P&gt;I need them to remain as character values because I need the leading 0's.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 16:41:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837734#M101404</guid>
      <dc:creator>patriciafm811</dc:creator>
      <dc:date>2025-02-07T16:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837735#M101405</link>
      <description>&lt;P&gt;Ok, in that case either create new numeric column for them or use Num for the conversion (of course your 5 digits apart can mean something else than the numeric difference between them).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide all the rules you have in order if importance, for example I'm not sure how center codes are related to this (you did mention them)&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You want to find rows which have UNC values maximum difference of 5 (I assume that is what it means to be 5 digits different)&lt;/LI&gt;
&lt;LI&gt;Then you want values which are at maximum 30 minutes apart while filling rule 1&lt;/LI&gt;
&lt;LI&gt;Center codes?&lt;/LI&gt;
&lt;LI&gt;Anything else?&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 07 Feb 2025 16:52:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837735#M101405</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-07T16:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837746#M101407</link>
      <description>&lt;P&gt;The rules you put are fairly correct. The center code is just the identifier for each center. The center code is the first 3 digits of the UCN if that helps. I already have it in my script and main file (which is huge) to filter down from about 12k rows to this 120. That one does the UCNs withing 5 digits.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The next step is determining if the similar UCNs have a timestamp within 30 minutes of each other (for the same center and within 5 digits of the UCN). That is what I am trying to figure out how to do. The formula I am currently using that isn't working should be listed in the column formula option in the table I uploaded earlier.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 17:24:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837746#M101407</guid>
      <dc:creator>patriciafm811</dc:creator>
      <dc:date>2025-02-07T17:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837748#M101408</link>
      <description>&lt;P&gt;Not sure if this formula is correct as it disagrees quite heavily with your formula&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Current Data Table() &amp;lt;&amp;lt; New Column("R", Numeric, Nominal, Formula(
	If(:Center Code == Lag(:Center Code) | :Center Code == Lag(:Center Code , -1),
		If(Min(Abs(Dif(Num(:Pos UCN))), Abs(Dif(Num(:Pos UCN), -1))) &amp;lt;= 5,
			Min(Abs(Dif(:Unit Entry Timestamp)), Abs(Dif(:Unit Entry Timestamp, -1))) &amp;lt;= In Minutes(30)
		,
			0
		)
	,
		0
	);
));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1738950472533.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72675iB33789C22E0EAD2A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1738950472533.png" alt="jthi_0-1738950472533.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 17:48:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837748#M101408</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-07T17:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837749#M101409</link>
      <description>&lt;P&gt;This is the formula i have to get my within 5 column&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;JSL&amp;gt;&lt;/P&gt;&lt;P&gt;If( Dif( Num( :Pos UCN ), 1 ) &amp;lt;= 5 | Abs( Dif( Num( :Pos UCN ), -1 ) ) &amp;lt;= 5,&lt;BR /&gt;1,&lt;BR /&gt;0&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 17:52:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837749#M101409</guid>
      <dc:creator>patriciafm811</dc:creator>
      <dc:date>2025-02-07T17:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837750#M101410</link>
      <description>&lt;P&gt;I just realized I hadnt included that column in my original question..&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 17:55:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837750#M101410</guid>
      <dc:creator>patriciafm811</dc:creator>
      <dc:date>2025-02-07T17:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Find time difference between rows</title>
      <link>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837751#M101411</link>
      <description>&lt;P&gt;This formula was EXACTLY what I needed!!!!! Thank you!!!&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 18:00:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-time-difference-between-rows/m-p/837751#M101411</guid>
      <dc:creator>patriciafm811</dc:creator>
      <dc:date>2025-02-07T18:00:51Z</dc:date>
    </item>
  </channel>
</rss>

