<?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: Adding x number of days to a Character Date column (dd-Mon-YYYY) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Adding-x-number-of-days-to-a-Character-Date-column-dd-Mon-YYYY/m-p/369080#M61894</link>
    <description>&lt;P&gt;The attached table adds 4 days to your available date column to get the target date.&amp;nbsp; Steps:&amp;nbsp; change the data type for available date to numeric/continuous with appropriate date formatting; then use the Date Increment function to add 4 days to the available date, finally change the formatting for the resulting target date column to match what you used in the available date column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One additional note - in your example, it looks like you added a week (7 days rather than 4).&lt;/P&gt;</description>
    <pubDate>Thu, 18 Mar 2021 15:10:59 GMT</pubDate>
    <dc:creator>dale_lehman</dc:creator>
    <dc:date>2021-03-18T15:10:59Z</dc:date>
    <item>
      <title>Adding x number of days to a Character Date column (dd-Mon-YYYY)</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-x-number-of-days-to-a-Character-Date-column-dd-Mon-YYYY/m-p/369071#M61893</link>
      <description>&lt;P&gt;I have a JSL script that periodically pulls data from an Access database.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The access database contains a date column "Available Date" with a dd-Mon-YYYY (E.g., 12-APR-2018) format. What I am trying to do, is create a new column "Target Date" in JMP that adds x number of days to the date in "Available Date" for each row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For example:&amp;nbsp;&lt;/STRONG&gt;In the image below, the Target date is equal to Available date + 4 days. I am trying to automatically calculate the Target date based on the Available date. The number of days is based on the "Time (Months)" column.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DanAlexander_1-1616079327448.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31350i59606F6FB9EFBED2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DanAlexander_1-1616079327448.png" alt="DanAlexander_1-1616079327448.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I've tried so far, which obviously does not work. I think I need to convert the "Available Date" column to a numeric data type, then add the number of days &amp;amp; convert back to Character?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column("Target Date", "Character", "Nominal");

dt &amp;lt;&amp;lt; For Each Row(
	IF (:"Time (Months)" &amp;lt;= 3, :"Target Date" = :"Available Date" + 4 ),
	IF (:"Time (Months)" &amp;gt; 3, :"Target Date" = :"Available Date" + 7 )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:08:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-x-number-of-days-to-a-Character-Date-column-dd-Mon-YYYY/m-p/369071#M61893</guid>
      <dc:creator>DanAlexander</dc:creator>
      <dc:date>2023-06-09T22:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Adding x number of days to a Character Date column (dd-Mon-YYYY)</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-x-number-of-days-to-a-Character-Date-column-dd-Mon-YYYY/m-p/369080#M61894</link>
      <description>&lt;P&gt;The attached table adds 4 days to your available date column to get the target date.&amp;nbsp; Steps:&amp;nbsp; change the data type for available date to numeric/continuous with appropriate date formatting; then use the Date Increment function to add 4 days to the available date, finally change the formatting for the resulting target date column to match what you used in the available date column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One additional note - in your example, it looks like you added a week (7 days rather than 4).&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 15:10:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-x-number-of-days-to-a-Character-Date-column-dd-Mon-YYYY/m-p/369080#M61894</guid>
      <dc:creator>dale_lehman</dc:creator>
      <dc:date>2021-03-18T15:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Adding x number of days to a Character Date column (dd-Mon-YYYY)</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-x-number-of-days-to-a-Character-Date-column-dd-Mon-YYYY/m-p/369108#M61895</link>
      <description>&lt;P&gt;Unless there is a real reason to keep the Target Date values as a character column, I suggest you convert it to a JMP Date column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

dt &amp;lt;&amp;lt; new column( "Target Date", format( "ddmonyyyy") );

for each row(
	if( :"Time (Months)"n &amp;lt;= 3,
		:Target Date = 
			Informat( :Available Date, "ddmonyyyy" ) + In Days( 4 ),
		:Target Date = 
			Informat( :Available Date, "ddmonyyyy" ) + In Days( 7 )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="d1.PNG" style="width: 535px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31351i563A44C242457D0D/image-size/large?v=v2&amp;amp;px=999" role="button" title="d1.PNG" alt="d1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It is very easy to convert the above output to character by the below modification&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

dt &amp;lt;&amp;lt; new column( "Target Date", character );

for each row(
	if( :"Time (Months)"n &amp;lt;= 3,
		:Target Date = format(
			Informat( :Available Date, "ddmonyyyy" ) + In Days( 4 ),
			"ddmonyyyy"
		),
		:Target Date = format(
			Informat( :Available Date, "ddmonyyyy" ) + In Days( 7 ),
			"ddmonyyyy"
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="d2.PNG" style="width: 514px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31352i759FC8853926EE42/image-size/large?v=v2&amp;amp;px=999" role="button" title="d2.PNG" alt="d2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If the output format needs to be exactly as the input data format is, the following will get that accomplished&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

dt &amp;lt;&amp;lt; new column( "Target Date", character );

monthList = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP",
"OCT", "NOV", "DEC"};
for each row(
	if( :"Time (Months)"n &amp;lt;= 3,
		temp = Informat( :Available Date, "ddmonyyyy" ) + In Days( 4 ),
		temp = Informat( :Available Date, "ddmonyyyy" ) + In Days( 7 )
	);
	:Target Date = Substr( "0", Length( Char( Day( temp ) ) ) ) ||
	Char( Day( temp ) ) || "-" || monthList[Month( temp )] || "-" ||
	Char( Year( temp ) );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="d3.PNG" style="width: 525px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31353i7595871343EBB232/image-size/large?v=v2&amp;amp;px=999" role="button" title="d3.PNG" alt="d3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If you wanted to use a formula rather than the For Each Row, this would be for formula for the above output&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;monthList = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
If( :"Time (Months)"n &amp;lt;= 3,
	temp = Informat( :Available Date, "ddmonyyyy" ) + In Days( 4 ),
	temp = Informat( :Available Date, "ddmonyyyy" ) + In Days( 7 )
);
Substr( "0", Length( Char( Day( temp ) ) ) ) || Char( Day( temp ) ) || "-" || monthList[Month( temp )] || "-" ||
Char( Year( temp ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Mar 2021 16:03:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-x-number-of-days-to-a-Character-Date-column-dd-Mon-YYYY/m-p/369108#M61895</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-03-18T16:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Adding x number of days to a Character Date column (dd-Mon-YYYY)</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-x-number-of-days-to-a-Character-Date-column-dd-Mon-YYYY/m-p/369238#M61901</link>
      <description>This is excellent, exactly what I was trying to do - and so simple! Thank you for the help. I will leave it in the date format.</description>
      <pubDate>Thu, 18 Mar 2021 19:25:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-x-number-of-days-to-a-Character-Date-column-dd-Mon-YYYY/m-p/369238#M61901</guid>
      <dc:creator>DanAlexander</dc:creator>
      <dc:date>2021-03-18T19:25:07Z</dc:date>
    </item>
  </channel>
</rss>

