<?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 How to pass a date to an SQL Query in JMP in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-pass-a-date-to-an-SQL-Query-in-JMP/m-p/222244#M44350</link>
    <description>I’m getting a data sheet via SQL into JMP. One column is a :Date column. I’d like to pick the last date (Max value) or "last date-1 day" from this :Date column and transfer this date into an update querry, where CustomSQL( “ … Date &amp;gt;= ...) is.</description>
    <pubDate>Mon, 19 Aug 2019 17:53:45 GMT</pubDate>
    <dc:creator>Thomas1</dc:creator>
    <dc:date>2019-08-19T17:53:45Z</dc:date>
    <item>
      <title>How to pass a date to an SQL Query in JMP</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-pass-a-date-to-an-SQL-Query-in-JMP/m-p/222244#M44350</link>
      <description>I’m getting a data sheet via SQL into JMP. One column is a :Date column. I’d like to pick the last date (Max value) or "last date-1 day" from this :Date column and transfer this date into an update querry, where CustomSQL( “ … Date &amp;gt;= ...) is.</description>
      <pubDate>Mon, 19 Aug 2019 17:53:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-pass-a-date-to-an-SQL-Query-in-JMP/m-p/222244#M44350</guid>
      <dc:creator>Thomas1</dc:creator>
      <dc:date>2019-08-19T17:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a date to an SQL Query in JMP</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-pass-a-date-to-an-SQL-Query-in-JMP/m-p/222402#M44377</link>
      <description>&lt;P&gt;Hi Thomas,&lt;/P&gt;&lt;P&gt;here's a small script, that may perform your task,&lt;/P&gt;&lt;P&gt;the first part is only to create a sample table (you already may have),&lt;/P&gt;&lt;P&gt;the second is the important one for you, and you can change to your needs.&lt;/P&gt;&lt;P&gt;To better understand you can execute it line by line, and have a look at the log to see what happens.&lt;/P&gt;&lt;P&gt;Georg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// 1st part, generate table
// make a table and fill it with some data
dt = New Table( "Query Data",
	Add Rows( 1e2 ),
	New Column( "Wafer", set each value( Row() ) ),
	New Column( "Machine", Character, set each value( If( Row() &amp;lt; 50, "A", "B" ) ) ),
	New Column( "date",
		Numeric,
		Format( "d.m.y", 10 ),
		Input Format( "d.m.y" ),
		set each value( Date Increment( Date DMY( 19, 8, 2019 ), "Day", -1 * Row() ) )
	),
	New Column( "value", set each value( Random Normal( 100, 10 ) ) ), 
);

// add a script (oracle sql query with date placeholder &amp;amp;DATE )
dt &amp;lt;&amp;lt; New Property( "MySQLQuery", "select * from some_table where date &amp;gt; to_date('&amp;amp;DATE', 'dd.mm.yyyy') " );

// 2nd part, perform task

// get max date
max_date = Col Max( dt:date );
Show( Day( max_date ), Month( max_date ), Year( max_date ) );

// modify and convert max date to string
my_query = dt &amp;lt;&amp;lt; get Property( "MySQLQuery" );
date_string = Right( "0" || Char( Day( max_date ) - 3 /* subtract some days */ ), 2 ) || "." || Right( "0" || Char( Month( max_date ) ), 2 ) || "."
 || Char( Year( max_date ) );
Show( date_string );

// replace query with changed date in table
Substitute Into( my_query, "&amp;amp;DATE", date_string );
dt &amp;lt;&amp;lt; set property( "MySQLQuery", Eval( my_query ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Aug 2019 15:22:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-pass-a-date-to-an-SQL-Query-in-JMP/m-p/222402#M44377</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2019-08-20T15:22:04Z</dc:date>
    </item>
  </channel>
</rss>

