<?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: Having custom date range in SQL based on user input variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34344#M20354</link>
    <description>&lt;P&gt;You have to match the hatch for your different dates. &amp;nbsp;The dates coming from JMP have one date mask, while the dates in your database have another one. &amp;nbsp;This should do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;nw = new window("Scrap Data", &amp;lt;&amp;lt; modal(),
    panelbox("Enter Date Range",
       lineup box(ncol(2),
            text box("From Date: "),
            fromdate_teb = text edit box(format(today(),"y/m/d h:m:s"), &amp;lt;&amp;lt; set width (150)),

            text box("To Date: "),
            todate_teb = text edit box(format(today(),"y/m/d h:m:s") , &amp;lt;&amp;lt; set width (150)),
        ),
    ),       
    panelbox("Actions",
        hlistbox(
            ok_button = button box("OK",
                        fromdate = fromdate_teb  &amp;lt;&amp;lt; get text();
                        todate = todate_teb &amp;lt;&amp;lt; get text();
                        ok_pushed = 1;),
            cancel_button = button box("Cancel", ok_pushed = 0),
        )
    )
);
print(fromdate, todate);

sql = evalinsert(
"SELECT
       p.productname,
       p.model,
       p.family,
       TO_DATE(SUBSTR (txntime, 1, 15), 'yyyymmdd hh24miss') txntime
  FROM database p
 WHERE TO_DATE(SUBSTR (txntime, 1, 15), 'yyyymmdd hh24miss') &amp;gt;= to_date('^fromdate^', 'yyyy/mm/dd hh:mi:ss am')
   AND TO_DATE(SUBSTR (txntime, 1, 15), 'yyyymmdd hh24miss') &amp;lt; to_date('^todate^', 'yyyy/mm/dd hh:mi:ss am')");

Open Database("Generic database connection string", sql, "New_Table");
print(sql);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 11 Jan 2017 13:41:50 GMT</pubDate>
    <dc:creator>pmroz</dc:creator>
    <dc:date>2017-01-11T13:41:50Z</dc:date>
    <item>
      <title>Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34155#M20254</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having issues while trying to have a custom user input based variable into my SQL code. The problem with the database I am connecting is that the date column is character. So here is the actual code that works well with hard coded dates inside the SQL query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Open Database("Generic database connection string",&lt;BR /&gt; " SELECT&lt;BR /&gt; p.productname,&lt;BR /&gt; p.model,&lt;BR /&gt; p.family,&lt;BR /&gt; TO_DATE (SUBSTR (txntime, 1, 15), 'yyyy/mm/dd hh24miss') txntime&lt;BR /&gt; FROM database p&lt;BR /&gt; &lt;BR /&gt;WHERE &lt;BR /&gt; txntime &amp;gt;= '20161201 000000000'&lt;BR /&gt; AND txntime &amp;lt; '20161231 000000000'&lt;BR /&gt; ", &lt;BR /&gt; // End of SQL statement&lt;BR /&gt;"New_Table" // New table name&lt;BR /&gt;);&lt;/PRE&gt;&lt;P&gt;The picture below shows the sample view on how the dates are saved in this table. Column property is Character &amp;amp; Nominal.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Date column sample.JPG" style="width: 120px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4688iC886673AFFF49669/image-size/large?v=v2&amp;amp;px=999" role="button" title="Date column sample.JPG" alt="Date column sample.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I tried to insert user input variable. This code returns an empty table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Delete Symbols();
Delete Globals();
nw = new window("Scrap Data", &amp;lt;&amp;lt; modal(),
    panelbox("Enter Date Range",
       hlistbox(
            text box("From Date"),
            fromdate_teb = text edit box("%", &amp;lt;&amp;lt; set width (100)),
        ),
        hlistbox(
            text box("To Date"),
            todate_teb = text edit box("%" , &amp;lt;&amp;lt; set width (100)),
        ),
                
        ),
    panelbox("Actions",
        hlistbox(
            ok_button = button box("OK",
                        fromdate = fromdate_teb  &amp;lt;&amp;lt; get text;
                        todate = todate_teb &amp;lt;&amp;lt; get text;
                        ok_pushed = 1;),
            cancel_button = button box("Cancel", ok_pushed = 0),
        )
    )
);

Open Database("Generic database connection string",
      " SELECT
       p.productname,
       p.model,
       p.family,
       TO_DATE (SUBSTR (txntime, 1, 15), 'yyyy/mm/dd hh24miss') txntime
  FROM database p
      
WHERE     
       txntime &amp;gt;= &lt;FONT color="#FF0000"&gt;'^fromdate^'&lt;/FONT&gt;
       AND txntime &amp;lt; &lt;FONT color="#FF0000"&gt;'^todate^'&lt;/FONT&gt;
      ",    
        // End of SQL statement
"New_Table" // New table name --&amp;gt; can be changed as per requirements
);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2017 00:08:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34155#M20254</guid>
      <dc:creator>bharathu</dc:creator>
      <dc:date>2017-01-07T00:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34159#M20257</link>
      <description>&lt;P&gt;Try this and see if it works for you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Delete Symbols();
Delete Globals();
nw = New Window( "Scrap Data",
	&amp;lt;&amp;lt;modal(),
	Panel Box( "Enter Date Range",
		H List Box( Text Box( "From Date" ), fromdate_teb = Text Edit Box( "%", &amp;lt;&amp;lt;set width( 100 ) ), ),
		H List Box( Text Box( "To Date" ), todate_teb = Text Edit Box( "%", &amp;lt;&amp;lt;set width( 100 ) ), ), 
                
	),
	Panel Box( "Actions",
		H List Box(
			ok_button = Button Box( "OK",
				fromdate = fromdate_teb &amp;lt;&amp;lt; get text;
				todate = todate_teb &amp;lt;&amp;lt; get text;
				ok_pushed = 1;
			),
			cancel_button = Button Box( "Cancel", ok_pushed = 0 ),

		)
	)
);

Eval(
	Substitute(
			Expr(
				Open Database(
					"Generic database connection string",
					" SELECT
       p.productname,
       p.model,
       p.family,
       TO_DATE (SUBSTR (txntime, 1, 15), 'yyyy/mm/dd hh24miss') txntime
  FROM database p
      
WHERE     
       txntime &amp;gt;= __From_Date__
       AND txntime &amp;lt; __To_Date__
      ",    
        // End of SQL statement
					"New_Table" // New table name --&amp;gt; can be changed as per requirements
				)
			),
		Expr( __From_Date__ ), Parse( "'" || fromdate || "'" ),
		Expr( __To_Date__ ), Parse( "'" || todate || "'" )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:20:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34159#M20257</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-01-05T22:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34168#M20260</link>
      <description>&lt;P&gt;I think you need to enforce the format for the from date and to&amp;nbsp;date which the user enters so I've provided an option. However, I think the major issue is in the where statement so I've provided an option which should get you close to what you need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Delete Symbols();
Delete Globals();
nw = new window("Scrap Data", &amp;lt;&amp;lt; modal(),
    panelbox("Enter Date Range",
       hlistbox(
            text box("From Date"),
            fromdate_teb = text edit box(format(today(),"y/m/d h:m:s"), &amp;lt;&amp;lt; set width (100)),
        ),
        hlistbox(
            text box("To Date"),
            todate_teb = text edit box(format(today(),"y/m/d h:m:s") , &amp;lt;&amp;lt; set width (100)),
        ),
                
        ),
    panelbox("Actions",
        hlistbox(
            ok_button = button box("OK",
                        fromdate = fromdate_teb  &amp;lt;&amp;lt; get text();
                        todate = todate_teb &amp;lt;&amp;lt; get text();
                        ok_pushed = 1;),
            cancel_button = button box("Cancel", ok_pushed = 0),
        )
    )
);

Open Database("Generic database connection string",
      " SELECT
       p.productname,
       p.model,
       p.family,
       TO_DATE (SUBSTR (txntime, 1, 15), 'yyyy/mm/dd hh24:mi:ss') txntime
  FROM database p
      
WHERE     
       txntime &amp;gt;= to_date('"|| fromdate || "', 'yyyy/mm/dd hh:mi:ss am')
       AND txntime &amp;lt; to_date('"|| todate || "', 'yyyy/mm/dd hh:mi:ss am')
      ",    
        // End of SQL statement
"New_Table" // New table name --&amp;gt; can be changed as per requirements
);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 23:01:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34168#M20260</guid>
      <dc:creator>mark_anawis</dc:creator>
      <dc:date>2017-01-05T23:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34265#M20293</link>
      <description>&lt;P&gt;Hello Jim,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply, but I am still having issues. Here are the snap shots of my input and the corresponding errors seen in the log&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Input type 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sol1 ip1.png" style="width: 214px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4737i64DB1E0AD738D2AB/image-size/large?v=v2&amp;amp;px=999" role="button" title="sol1 ip1.png" alt="sol1 ip1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sol1 op1.png" style="width: 401px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4739iDC8EBCEB58BB3C89/image-size/large?v=v2&amp;amp;px=999" role="button" title="sol1 op1.png" alt="sol1 op1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Input type 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sol1 ip2.png" style="width: 214px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4740i76D7EE11C7CE1776/image-size/large?v=v2&amp;amp;px=999" role="button" title="sol1 ip2.png" alt="sol1 ip2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sol1 op2.png" style="width: 416px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4741i489C434BA4CD21C3/image-size/large?v=v2&amp;amp;px=999" role="button" title="sol1 op2.png" alt="sol1 op2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a feeling the problem is coming from this part of the code but I am still a learning JSL. I would appretiate feedback from experts like you. Is there any way that we can directly use the user input variable "fromdate" &amp;amp; "todate" directly in SQL?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sol1 error.JPG" style="width: 520px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4742i79118F6E027FCF7C/image-size/large?v=v2&amp;amp;px=999" role="button" title="sol1 error.JPG" alt="sol1 error.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2017 00:00:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34265#M20293</guid>
      <dc:creator>bharathu</dc:creator>
      <dc:date>2017-01-07T00:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34271#M20295</link>
      <description>&lt;P&gt;Hello Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply as well. I am having issues with this code as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the snap shots of my user input in the text box and the error that I am seeing in the log&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sol2 ip1.png" style="width: 264px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4745iBBD511A2AECBCECC/image-size/large?v=v2&amp;amp;px=999" role="button" title="sol2 ip1.png" alt="sol2 ip1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sol2 op1.JPG" style="width: 562px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4746iA2DB4C3AD28CF312/image-size/large?v=v2&amp;amp;px=999" role="button" title="sol2 op1.JPG" alt="sol2 op1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2017 00:11:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34271#M20295</guid>
      <dc:creator>bharathu</dc:creator>
      <dc:date>2017-01-07T00:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34273#M20296</link>
      <description>&lt;P&gt;The biggest reason for this problem is that the database I am dealing with has time stamp is a character format. :(&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Date column sample.JPG" style="width: 120px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4747i1204E7E5C25782B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Date column sample.JPG" alt="Date column sample.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2017 00:15:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34273#M20296</guid>
      <dc:creator>bharathu</dc:creator>
      <dc:date>2017-01-07T00:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34313#M20331</link>
      <description>&lt;P&gt;The date and format of the date in the TO_DATE function need to match.&lt;/P&gt;&lt;P&gt;Try this in the select section of the script I sent:&lt;/P&gt;&lt;P&gt;TO_DATE(&lt;BR /&gt;SUBSTR (txntime, 1,4)||"/"||SUBSTR(txntime,5,2)||"/"||SUBSTR(txntime,7,2)||" "||&lt;BR /&gt;SUBSTR(txntime,10,2)||":"||SUBSTR(txntime,12,2)||":"||SUBSTR(txntime,14,2),&lt;BR /&gt;'yyyy/mm/dd hh24:mi:ss') txntime&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 20:10:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34313#M20331</guid>
      <dc:creator>mark_anawis</dc:creator>
      <dc:date>2017-01-09T20:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34338#M20350</link>
      <description>&lt;P&gt;Thanks Mark but unfortunately I am seeing the following error when trying to execute&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JMP alert.JPG" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4753i58469EFC797A1AE4/image-size/large?v=v2&amp;amp;px=999" role="button" title="JMP alert.JPG" alt="JMP alert.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error seems to be caused due to the concatenation of the space between the date &amp;amp; the time (highlighted in red). Is there any other way to have the space in between the date &amp;amp; the time?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TO_DATE(SUBSTR (txntime, 1,4)||"/"||SUBSTR(txntime,5,2)||"/"||SUBSTR(txntime,7,2)||&lt;FONT color="#FF0000"&gt;" "&lt;/FONT&gt;||SUBSTR(txntime,10,2)||":"||SUBSTR(txntime,12,2)||":"||SUBSTR(txntime,14,2),'yyyy/mm/dd hh24:mi:ss') txntime&lt;/PRE&gt;&lt;P&gt;Also I have a question about the text 'am' for the where clause. Could you let me know why is it needed there?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture1.png" style="width: 906px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4754i4429089636DE67DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Picture1.png" alt="Picture1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 00:36:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34338#M20350</guid>
      <dc:creator>bharathu</dc:creator>
      <dc:date>2017-01-11T00:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34344#M20354</link>
      <description>&lt;P&gt;You have to match the hatch for your different dates. &amp;nbsp;The dates coming from JMP have one date mask, while the dates in your database have another one. &amp;nbsp;This should do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;nw = new window("Scrap Data", &amp;lt;&amp;lt; modal(),
    panelbox("Enter Date Range",
       lineup box(ncol(2),
            text box("From Date: "),
            fromdate_teb = text edit box(format(today(),"y/m/d h:m:s"), &amp;lt;&amp;lt; set width (150)),

            text box("To Date: "),
            todate_teb = text edit box(format(today(),"y/m/d h:m:s") , &amp;lt;&amp;lt; set width (150)),
        ),
    ),       
    panelbox("Actions",
        hlistbox(
            ok_button = button box("OK",
                        fromdate = fromdate_teb  &amp;lt;&amp;lt; get text();
                        todate = todate_teb &amp;lt;&amp;lt; get text();
                        ok_pushed = 1;),
            cancel_button = button box("Cancel", ok_pushed = 0),
        )
    )
);
print(fromdate, todate);

sql = evalinsert(
"SELECT
       p.productname,
       p.model,
       p.family,
       TO_DATE(SUBSTR (txntime, 1, 15), 'yyyymmdd hh24miss') txntime
  FROM database p
 WHERE TO_DATE(SUBSTR (txntime, 1, 15), 'yyyymmdd hh24miss') &amp;gt;= to_date('^fromdate^', 'yyyy/mm/dd hh:mi:ss am')
   AND TO_DATE(SUBSTR (txntime, 1, 15), 'yyyymmdd hh24miss') &amp;lt; to_date('^todate^', 'yyyy/mm/dd hh:mi:ss am')");

Open Database("Generic database connection string", sql, "New_Table");
print(sql);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Jan 2017 13:41:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34344#M20354</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-01-11T13:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34442#M20393</link>
      <description>&lt;P&gt;Thank you so much. This script is working great and I am getting the data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 19:47:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34442#M20393</guid>
      <dc:creator>bharathu</dc:creator>
      <dc:date>2017-01-12T19:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34491#M20420</link>
      <description>&lt;P&gt;Is there a way to have same user input fromt he text box work on another database SQL pull within the same script? &lt;STRONG&gt;The only catch is this new database follows traditional/standard numeric type date column. Is there a way to convert the user inputs (fromdate &amp;amp; todate) to secondarly variables with a numeric format month-day-year? Primary character based dates to be used for the issue that is already solved and secondary set to extract data based on numeric dates.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my SQL that I am trying to use for extracting yield data from another database.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;nw = new window("New Window for user input", &amp;lt;&amp;lt; modal(),
    panelbox("Enter Date Range",
       lineup box(ncol(2),
            text box("From Date: "),
            fromdate_teb = text edit box(format(today(),"y/m/d h:m:s"), &amp;lt;&amp;lt; set width (150)),

            text box("To Date: "),
            todate_teb = text edit box(format(today(),"y/m/d h:m:s") , &amp;lt;&amp;lt; set width (150)),
        ),
    ),       
    panelbox("Actions",
        hlistbox(
            ok_button = button box("OK",
                        fromdate = fromdate_teb  &amp;lt;&amp;lt; get text();
                        todate = todate_teb &amp;lt;&amp;lt; get text();
                        ok_pushed = 1;),
            cancel_button = button box("Cancel", ok_pushed = 0),
        )
    )
);
print(fromdate, todate);

Yieldsql = evalinsert(
" SELECT    
        model,
        lot,
        wafer,
        COUNT(test_status_code) as BIN_COUNT
    FROM
        test_data
    WHERE
        purpose='PROD'
        AND test_data.test_date BETWEEN TO_DATE('^fromdate^', 'MM/DD/YYYY hh24:mi:ss') AND TO_DATE('^todate^', 'MM/DD/YYYY hh24:mi:ss')
        
    ORDER by lot, wafer");


dt = Open Database(	"Generic database connection string", Yieldsql, "Yield_Data");&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 22:00:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34491#M20420</guid>
      <dc:creator>bharathu</dc:creator>
      <dc:date>2017-01-13T22:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34494#M20423</link>
      <description>Fixed it by correcting the WHERE clause for test_date&lt;BR /&gt;&lt;BR /&gt;AND test_data.test_date BETWEEN TO_DATE('^fromdate^', 'YYYY/MM/DD hh:mi:ss am') AND TO_DATE('^todate^', 'YYYY/MM/DD hh:mi:ss am')&lt;BR /&gt;&lt;BR /&gt;Now I am able to use the same input date variables across 2 databases in the same query. One query pulls data with numeric dates and another sql pulls data where dates are character based.</description>
      <pubDate>Sat, 14 Jan 2017 00:01:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/34494#M20423</guid>
      <dc:creator>bharathu</dc:creator>
      <dc:date>2017-01-14T00:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Having custom date range in SQL based on user input variable</title>
      <link>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/43967#M25365</link>
      <description>&lt;P&gt;Thank you for the assistance. This worked perfectly!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 18:23:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Having-custom-date-range-in-SQL-based-on-user-input-variable/m-p/43967#M25365</guid>
      <dc:creator>Bandfield</dc:creator>
      <dc:date>2017-09-05T18:23:49Z</dc:date>
    </item>
  </channel>
</rss>

