cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
terapin
Level VI

Use date variable in Open Database JSL command

I have a JSL script that opens a SQL database and then processes the data for various purposes.  My challenge is passing a date variable to the Open Database command to further refine the automation of the process.  I've tried a whole host of options for trying to do this, but nothing has worked so far.  Does anyone have any suggestions for how I can replace the Date_Time value listed in the Open Database command with the variable datetime shown below?

datetime = "2021-08-01";

// Program opens diagnostic SQL data table for all instruments
dt.db_diag = Open Database(
"DSN=AQM;Description=AQM;UID=sa;PWD=LKJDFDF;Trusted_Connection=No;APP=JMP;WSID=TESTPC;DATABASE=EnvidasConfig;",
"SELECT * FROM [dbo].MonitorDiagnosticsData WHERE Date_Time >= '2021-08-18'"
);
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Use date variable in Open Database JSL command

See if this will do what you need

datetime = "2021-08-01";

// Program opens diagnostic SQL data table for all instruments


Eval(
	Parse(
		"dt.db_diag = Open Database(
\!"DSN=AQM;Description=AQM;UID=sa;PWD=LKJDFDF;Trusted_Connection=No;APP=JMP;WSID=TESTPC;DATABASE=EnvidasConfig;\!",
\!"SELECT * FROM [dbo].MonitorDiagnosticsData WHERE Date_Time >= '"
		 || datetime || "'\!"
);"
	)
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Use date variable in Open Database JSL command

See if this will do what you need

datetime = "2021-08-01";

// Program opens diagnostic SQL data table for all instruments


Eval(
	Parse(
		"dt.db_diag = Open Database(
\!"DSN=AQM;Description=AQM;UID=sa;PWD=LKJDFDF;Trusted_Connection=No;APP=JMP;WSID=TESTPC;DATABASE=EnvidasConfig;\!",
\!"SELECT * FROM [dbo].MonitorDiagnosticsData WHERE Date_Time >= '"
		 || datetime || "'\!"
);"
	)
);
Jim
terapin
Level VI

Re: Use date variable in Open Database JSL command

That works perfectly,

 

I also now see where I was putting the ' in the wrong location during my testing.  Thanks for the quick and helpful reply.

Recommended Articles