<?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: changing date format in a query in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33495#M19883</link>
    <description>&lt;P&gt;Hey, mallen810,&lt;/P&gt;
&lt;P&gt;Can you provide a little more detail on what you are trying to do, like what the date computation looks like? &amp;nbsp;When the data gets back to JMP, is it a number formatted as a date, or is it character data? &amp;nbsp;Screen shots can be a big help.&lt;/P&gt;
&lt;P&gt;There are two possibilities - one is to figure out a way to make the computed date be recognized by JMP as a date, but if that is not possible, the workaround is to add some JSL in the Post Query Script of the query that will convert whatever comes back from the database into a proper JMP date. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Dec 2016 13:25:21 GMT</pubDate>
    <dc:creator>Eric_Hill</dc:creator>
    <dc:date>2016-12-11T13:25:21Z</dc:date>
    <item>
      <title>changing date format in a query</title>
      <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33469#M19870</link>
      <description>&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;I am putting together a query and would like to make a computed column from my available columns.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;When this data is retreived from the sql data base it brings in the date in this format (month, day, year) in separate columns &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;What I would like to do is have a column returned in my query that has already combined the month, day, year format in a seperate column as (12/1/16) so I can graph the data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 20:09:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33469#M19870</guid>
      <dc:creator>mallen810</dc:creator>
      <dc:date>2016-12-09T20:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: changing date format in a query</title>
      <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33495#M19883</link>
      <description>&lt;P&gt;Hey, mallen810,&lt;/P&gt;
&lt;P&gt;Can you provide a little more detail on what you are trying to do, like what the date computation looks like? &amp;nbsp;When the data gets back to JMP, is it a number formatted as a date, or is it character data? &amp;nbsp;Screen shots can be a big help.&lt;/P&gt;
&lt;P&gt;There are two possibilities - one is to figure out a way to make the computed date be recognized by JMP as a date, but if that is not possible, the workaround is to add some JSL in the Post Query Script of the query that will convert whatever comes back from the database into a proper JMP date. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2016 13:25:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33495#M19883</guid>
      <dc:creator>Eric_Hill</dc:creator>
      <dc:date>2016-12-11T13:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: changing date format in a query</title>
      <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33525#M19904</link>
      <description>&lt;P&gt;What database are you querying? &amp;nbsp;I.e. Oracle, SQL Server etc.?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the original field in the database is already a date, why not just pull that field in directly? &amp;nbsp;JMP will treat that as a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the database has day, month, year in separate fields, you can combine them in SQL. &amp;nbsp;Here's an example using Oracle:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;SELECT to_date(to_char(a.month_field) ||&amp;nbsp;'/' || 
               to_char(a.day_field)   || '/' || 
               to_char(a.year_field), 'MM/DD/YYYY')
  FROM my_table a&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Dec 2016 14:42:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33525#M19904</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2016-12-12T14:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: changing date format in a query</title>
      <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33538#M19908</link>
      <description>&lt;P&gt;The original data is coming in from an SQL server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The date is recieved in three seperate colums.&lt;/P&gt;&lt;P&gt;I would like to add a date column in this querry from the available columns.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2016-12-12 at 10.24.25 AM.png" style="width: 752px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4529i88C0CB18E0F23CDF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2016-12-12 at 10.24.25 AM.png" alt="Screen Shot 2016-12-12 at 10.24.25 AM.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2016-12-12 at 10.23.58 AM.png" style="width: 244px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4528iC03404D69D3956B1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2016-12-12 at 10.23.58 AM.png" alt="Screen Shot 2016-12-12 at 10.23.58 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 15:33:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33538#M19908</guid>
      <dc:creator>mallen810</dc:creator>
      <dc:date>2016-12-12T15:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: changing date format in a query</title>
      <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33541#M19910</link>
      <description>&lt;P&gt;Here is the current sql&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2016-12-12 at 10.35.42 AM.png" style="width: 580px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4530i4FB26206AEAE1C09/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2016-12-12 at 10.35.42 AM.png" alt="Screen Shot 2016-12-12 at 10.35.42 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 15:37:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33541#M19910</guid>
      <dc:creator>mallen810</dc:creator>
      <dc:date>2016-12-12T15:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: changing date format in a query</title>
      <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33542#M19911</link>
      <description>&lt;P&gt;In SQL Server you can use the CONVERT or TRY_CONVERT functions to create a datetime value from individual components. &lt;A href="http://www.sqlines.com/oracle-to-sql-server/to_date" target="_self"&gt;This is a good link&lt;/A&gt; for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 15:38:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33542#M19911</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2016-12-12T15:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: changing date format in a query</title>
      <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33544#M19912</link>
      <description>&lt;P&gt;If you have SQL Server 2012 or later you can use the &lt;STRONG&gt;DATEFROMPARTS&lt;/STRONG&gt;&amp;nbsp;function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="lang-sql prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="kwd"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; DATEFROMPARTS&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(@t1.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;year&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;@t1.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;month&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;@t1.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;day&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;) AS my_date&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 15:47:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33544#M19912</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2016-12-12T15:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: changing date format in a query</title>
      <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33564#M19918</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pmroz's answer is great if you want to generate the date column on the server. &amp;nbsp;If you're okay with the date column being generated in JMP after the query finishes, you could add this JSL code to the&amp;nbsp;&lt;STRONG&gt;Post-Query Script&lt;/STRONG&gt; panel in Query Builder:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Column( "Date",
	Numeric,
	"Continuous",
	Format( "m/d/y", 12 ),
	Input Format( "m/d/y" ),
	Formula( Date MDY( :month, :day, :year ) ),
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;One advantage of doing it this way is that it work regardless of what database you have. &amp;nbsp;Of course, if all you have is SQL Server, you may not care about other databases....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 18:42:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33564#M19918</guid>
      <dc:creator>Eric_Hill</dc:creator>
      <dc:date>2016-12-12T18:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: changing date format in a query</title>
      <link>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33565#M19919</link>
      <description>&lt;P&gt;Thanks guys for all your responses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eric, just added the post query script and it worked perfect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;mallen810&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 18:48:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/changing-date-format-in-a-query/m-p/33565#M19919</guid>
      <dc:creator>mallen810</dc:creator>
      <dc:date>2016-12-12T18:48:50Z</dc:date>
    </item>
  </channel>
</rss>

