cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

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