<?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: How to Assign Date Values based on a Current Month Key in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-Assign-Date-Values-based-on-a-Current-Month-Key/m-p/424734#M67389</link>
    <description>&lt;P&gt;Here is one possible solution using Date Increment. Done as Formula but should be fairly easy to use in loop if you want to rename columns:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;CurMonth = 9;
currentDate = Date DMY(1, curmonth, Year(Today()));
Date Increment(currentDate, "Month", -1 * Num(:Month), "start");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;First curMonth is used to generate currentDate with the assumption that the start year is same as current year, then that date is used in Date Increment function.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1633698517107.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36421iCC0345FB8BF7E154/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1633698517107.png" alt="jthi_0-1633698517107.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Oct 2021 13:08:54 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2021-10-08T13:08:54Z</dc:date>
    <item>
      <title>How to Assign Date Values based on a Current Month Key</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Assign-Date-Values-based-on-a-Current-Month-Key/m-p/424708#M67387</link>
      <description>&lt;P&gt;I have data from a data base that assigns a column for the Current Month number when the data gets pulled, and then creates separate columns for previous months counting back. So for a 24 month data pull from September, there will be a column "Current Month" that has the value "9" for all rows, then it will have 24 columns with subscript header "_01", "_02", ..."_24", which denotes "Aug 2021", "Jul 2021",..."Sep 2019".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used a manual formula to put in each month, but would like to automate this using the "Current Month" value. I have no idea how to do this, for both the month and the year, since year is changing based on what the value is for Current Month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a data table script for a 24 month row example with a manually generated DateKey column based on the Current Month value being September:&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;dt=New Table( "Set Month with Key Example",
	Add Rows( 24 ),
	Compress File When Saved( 1 ),
	New Column( "Month",
		Character,
		"Nominal",
		Set Values(
			{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12",
			"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"}
		)
	),
	New Column( "DateKey",
		Character,
		Set Values(
			{"01082021", "01072021", "01062021", "01052021", "01042021", "01032021", "01022021", "01012021", "01122020", "01112020", "01102020", "01092020", "01082020", "01072020", "01062020", "01052020", "01042020", "01032020", "01022020", "01012020", "01122019", "01112019", "01102019", "01092019"}
		)
	)
); 
&lt;BR /&gt;dt:DateKey &amp;lt;&amp;lt; Data Type( Numeric, Format( "m/y", 8 ), Input Format( "ddmmyyyy" ) ) &amp;lt;&amp;lt;&lt;BR /&gt;Set Modeling Type( "Continuous" ) &amp;lt;&amp;lt; Set Field Width( 12 );

CurMonth=9;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Monique&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:01:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Assign-Date-Values-based-on-a-Current-Month-Key/m-p/424708#M67387</guid>
      <dc:creator>Mo</dc:creator>
      <dc:date>2023-06-09T18:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to Assign Date Values based on a Current Month Key</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Assign-Date-Values-based-on-a-Current-Month-Key/m-p/424734#M67389</link>
      <description>&lt;P&gt;Here is one possible solution using Date Increment. Done as Formula but should be fairly easy to use in loop if you want to rename columns:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;CurMonth = 9;
currentDate = Date DMY(1, curmonth, Year(Today()));
Date Increment(currentDate, "Month", -1 * Num(:Month), "start");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;First curMonth is used to generate currentDate with the assumption that the start year is same as current year, then that date is used in Date Increment function.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1633698517107.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36421iCC0345FB8BF7E154/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1633698517107.png" alt="jthi_0-1633698517107.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 13:08:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Assign-Date-Values-based-on-a-Current-Month-Key/m-p/424734#M67389</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-10-08T13:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to Assign Date Values based on a Current Month Key</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Assign-Date-Values-based-on-a-Current-Month-Key/m-p/424740#M67392</link>
      <description>&lt;P&gt;Thanks so much, that works great!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 13:19:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Assign-Date-Values-based-on-a-Current-Month-Key/m-p/424740#M67392</guid>
      <dc:creator>Mo</dc:creator>
      <dc:date>2021-10-08T13:19:40Z</dc:date>
    </item>
  </channel>
</rss>

