<?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: Calculate time difference in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Calculate-time-difference/m-p/54989#M31083</link>
    <description>&lt;P&gt;You are a true phenom.&amp;nbsp; Not being a software engineer, I spent a couple hours trying to do what I did and you solved it with a single equation.&amp;nbsp; Amazing.&amp;nbsp; Thank you.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Apr 2018 18:15:55 GMT</pubDate>
    <dc:creator>KST-CPT</dc:creator>
    <dc:date>2018-04-13T18:15:55Z</dc:date>
    <item>
      <title>Calculate time difference</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-time-difference/m-p/54980#M31079</link>
      <description>&lt;P&gt;I have a set od data, In the script I call it RTDT.&amp;nbsp; It contains a Time, Sub_name and Substrate_ID columns.&amp;nbsp; I am trying to calculate the time difference between the first time and last time a unique&amp;nbsp;&lt;SPAN&gt;Sub_name and Substrate_ID are listed. They will be listed sequentially for each unique&amp;nbsp;Sub_name and Substrate_ID.&amp;nbsp; My code is as follows:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;RTDT &amp;lt;&amp;lt; New Column( "Runtime", Numeric, "Continuous", Format( "h:m:s", 11, 0 ), Input Format( "h:m:s", 0 ), );
SubNameFirst = RTDT:Sub_name( 1 );
SNFirst = RTDT:Substrate_ID( 1 );
TimeFirst = RTDT:Time( 1 );
EOL = N Rows( RTDT );
&amp;nbsp;
For( i = 1, i &amp;lt;= EOL, i++,
	If( SubNameFirst != RTDT:Sub_name( i ) || SNFirst != RTDT:Substrate_ID( i ),
		Formula( RTDT:Runtime( i - 1 ) = (RTDT:Time( i - 1 ) - TimeFirst) );
		SubNameFirst = RTDT:Sub_name( i );
		SNFirst = RTDT:Substrate_ID( i );
		TimeFirst = RTDT:Time( i );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;All I get for results are ".".&amp;nbsp; Is my issue with format of the time column? I am thinking the if() statement never occurs because I get no results or errors.&lt;/P&gt;
&lt;P&gt;Any help would be appreciated.&amp;nbsp; Thanks&lt;/P&gt;
&lt;P&gt;Data table is attached.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 15:59:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-time-difference/m-p/54980#M31079</guid>
      <dc:creator>KST-CPT</dc:creator>
      <dc:date>2018-04-13T15:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-time-difference/m-p/54987#M31082</link>
      <description>&lt;P&gt;You appear to have a syntax issue.&amp;nbsp; You are using () for subscripting, where you should be using [].&amp;nbsp; Also, you seem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the only formula you need for your column called Runtime is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Max( :Time, :Sub_name, :Substrate_ID )
-Col Min( :Time, :Sub_name, :Substrate_ID )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;RTDT &amp;lt;&amp;lt; New Column( "Runtime",
	Numeric,
	"Continuous",
	Format( "h:m:s", 11, 0 ),
	Input Format( "h:m:s", 0 ),
	formula( Col Max( :Time, :Sub_name, :Substrate_ID ) - Col Min( :Time, :Sub_name, :Substrate_ID ) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Apr 2018 17:05:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-time-difference/m-p/54987#M31082</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-04-13T17:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-time-difference/m-p/54989#M31083</link>
      <description>&lt;P&gt;You are a true phenom.&amp;nbsp; Not being a software engineer, I spent a couple hours trying to do what I did and you solved it with a single equation.&amp;nbsp; Amazing.&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 18:15:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-time-difference/m-p/54989#M31083</guid>
      <dc:creator>KST-CPT</dc:creator>
      <dc:date>2018-04-13T18:15:55Z</dc:date>
    </item>
  </channel>
</rss>

