<?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 use evalinsert on SQL Query? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-use-evalinsert-on-SQL-Query/m-p/734087#M91516</link>
    <description>&lt;P&gt;Maybe your dates aren't correctly formatted? Most likely you are missing ' around the dates&lt;/P&gt;</description>
    <pubDate>Wed, 13 Mar 2024 06:54:29 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-03-13T06:54:29Z</dc:date>
    <item>
      <title>How to use evalinsert on SQL Query?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-evalinsert-on-SQL-Query/m-p/734064#M91512</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to query using a list and a variable. However, I cannot figure out how to query the dateNow variable. I keep on getting this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error occurred while trying to execute a query: [SQLState 42601] ERROR: syntax error at or near "00"&lt;BR /&gt;LINE 4: and test_date_time between 03/12/2024 00:00:00 AM and 03/12/...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my sample script:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;namecol= {"James", "John", "Anna", "Rose")
dateNow = "03/12/2024"
eval(parse(evalinsert("\[ 

	dt_qst = Try ( Open Database( "DSN=dbs;UID=uname;PWD=pw;APP=JMP;DATABASE=db;", 
"select name, age, address, test_date_time
from  db
where name in (^namecol^)
and test_date_time between ^dateNow^ 00:00:00 AM and ^dateNow^ 11:59:59 PM'", 
"rawdata") )
	
]\")));;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Mar 2024 06:05:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-evalinsert-on-SQL-Query/m-p/734064#M91512</guid>
      <dc:creator>UserID16644</dc:creator>
      <dc:date>2024-03-13T06:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use evalinsert on SQL Query?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-evalinsert-on-SQL-Query/m-p/734075#M91514</link>
      <description>&lt;P&gt;There are many small typos in your script which prevent it from working. Outside of that you need to use Concat Items to go from list to a string. Also to make it a bit easier to debug, build your query string outside of Open Database and then use that new string inside it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

namecol= {"James", "John", "Anna", "Rose"};
dateNow = "03/12/2024";

sql_template = "\[
select
	name, 
	age, 
	address, 
	test_date_time
from db
where
	name in ('^namestr^')
	and test_date_time between ^dateNow^ 00:00:00 AM and ^dateNow^ 11:59:59 PM'
]\";


namestr = Concat Items(namecol, "', '");

sql_str = Eval Insert(sql_template);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also think this has been basically answered already twice&lt;/P&gt;
&lt;P&gt;&lt;LI-MESSAGE title="How to skip item on JSL list in SQL query if it does not exist?" uid="730407" url="https://community.jmp.com/t5/Discussions/How-to-skip-item-on-JSL-list-in-SQL-query-if-it-does-not-exist/m-p/730407#U730407" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;and&amp;nbsp;&lt;LI-MESSAGE title="How to query in SQL using list from JSL" uid="730391" url="https://community.jmp.com/t5/Discussions/How-to-query-in-SQL-using-list-from-JSL/m-p/730391#U730391" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 06:26:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-evalinsert-on-SQL-Query/m-p/734075#M91514</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-03-13T06:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use evalinsert on SQL Query?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-evalinsert-on-SQL-Query/m-p/734086#M91515</link>
      <description>&lt;P&gt;Yes, but I don't understand why I kept on getting this error&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Error occurred while trying to execute a query: [SQLState 42601] ERROR: syntax error at or near "00"&lt;BR /&gt;LINE 10: and test_date_time between 03/12/2024 00:00:00 AM and 03/12...&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 06:45:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-evalinsert-on-SQL-Query/m-p/734086#M91515</guid>
      <dc:creator>UserID16644</dc:creator>
      <dc:date>2024-03-13T06:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use evalinsert on SQL Query?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-evalinsert-on-SQL-Query/m-p/734087#M91516</link>
      <description>&lt;P&gt;Maybe your dates aren't correctly formatted? Most likely you are missing ' around the dates&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 06:54:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-evalinsert-on-SQL-Query/m-p/734087#M91516</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-03-13T06:54:29Z</dc:date>
    </item>
  </channel>
</rss>

