<?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: Subtracting dates in column of table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Subtracting-dates-in-column-of-table/m-p/43098#M24970</link>
    <description>&lt;P&gt;JMP date values are measured in seconds, therefore to subtract a day from a given date, you need to subtract 60*60*24 seconds. &amp;nbsp;The following script creates a data table with a column that has a formula applied to it that subtracts 1 day from the first date column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );
New Table( "Test",
	Add Rows( 10 ),
	New Column( "date",
		Numeric,
		"Continuous",
		Format( "m/d/y", 12 ),
		Input Format( "mmddyyyy" ),
		Set Values(
			[3585254400, 3585254400, 3585254400, 3585254400, 3585254400, 3585254400,
			3585254400, 3585254400, 3585254400, 3585254400]
		)
	),
	New Column( "test end date",
		Numeric,
		"Continuous",
		Format( "m/d/y", 12 ),
		Input Format( "m/d/y" ),
		Formula( :date - 60 * 60 * 24 ),
		Set Selected
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also noticed in your attached picture, that your date value seems to be input into a character column, not as a numeric column, with an applied date format. &amp;nbsp;You will need to input the starting date value as a numeric date value if you are going to be able to do your subtraction.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Aug 2017 05:49:02 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2017-08-11T05:49:02Z</dc:date>
    <item>
      <title>Subtracting dates in column of table</title>
      <link>https://community.jmp.com/t5/Discussions/Subtracting-dates-in-column-of-table/m-p/43096#M24969</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could please help me write a script to subtract the dates by 1 day in one of my table columns and place them into a new column. This is easily done on excel, but I've been having a hard time trying to do&amp;nbsp;this in JMP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that in the picture, the column titled "TestEndDate" =06/19/2017 ... I want column titled"Test Start Date" to give me dates like 06/18/2017...&lt;/P&gt;&lt;P&gt;Also&amp;nbsp;know that the dates are not all the same in "TestEndDate"...&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 01:34:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subtracting-dates-in-column-of-table/m-p/43096#M24969</guid>
      <dc:creator>IrisK</dc:creator>
      <dc:date>2017-08-11T01:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting dates in column of table</title>
      <link>https://community.jmp.com/t5/Discussions/Subtracting-dates-in-column-of-table/m-p/43098#M24970</link>
      <description>&lt;P&gt;JMP date values are measured in seconds, therefore to subtract a day from a given date, you need to subtract 60*60*24 seconds. &amp;nbsp;The following script creates a data table with a column that has a formula applied to it that subtracts 1 day from the first date column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );
New Table( "Test",
	Add Rows( 10 ),
	New Column( "date",
		Numeric,
		"Continuous",
		Format( "m/d/y", 12 ),
		Input Format( "mmddyyyy" ),
		Set Values(
			[3585254400, 3585254400, 3585254400, 3585254400, 3585254400, 3585254400,
			3585254400, 3585254400, 3585254400, 3585254400]
		)
	),
	New Column( "test end date",
		Numeric,
		"Continuous",
		Format( "m/d/y", 12 ),
		Input Format( "m/d/y" ),
		Formula( :date - 60 * 60 * 24 ),
		Set Selected
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also noticed in your attached picture, that your date value seems to be input into a character column, not as a numeric column, with an applied date format. &amp;nbsp;You will need to input the starting date value as a numeric date value if you are going to be able to do your subtraction.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 05:49:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subtracting-dates-in-column-of-table/m-p/43098#M24970</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-08-11T05:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting dates in column of table</title>
      <link>https://community.jmp.com/t5/Discussions/Subtracting-dates-in-column-of-table/m-p/43100#M24972</link>
      <description>&lt;P&gt;Good catch on the character column! (JMP justifies character data left, numeric data right.)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are some helper functions for adding minutes, hours, days, weeks, and years. inDays(1) is 60*60*24:&lt;/P&gt;
&lt;PRE&gt;Show(&lt;BR /&gt;Format( Today(), "y/m/d" ),&lt;BR /&gt;Format( Today() - In Days( 1 ), "y/m/d" ),&lt;BR /&gt;Format( Today() - In Weeks( 1 ), "y/m/d" ),&lt;BR /&gt;Format( Today() - In Years( 1 ), "y/m/d" )&lt;BR /&gt;)&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Format(Today(), "y/m/d") = "2017/08/11";&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Format(Today() - In Days(1), "y/m/d") = "2017/08/10";&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Format(Today() - In Weeks(1), "y/m/d") = "2017/08/04";&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Format(Today() - In Years(1), "y/m/d") = "2016/08/11";&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The function&amp;nbsp;names refer to the argument units and each function returns a JMP duration in seconds.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 12:53:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subtracting-dates-in-column-of-table/m-p/43100#M24972</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2017-08-11T12:53:12Z</dc:date>
    </item>
  </channel>
</rss>

