- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Create a date time panel to extract SQL data
Hello,
I used to use a jmp script to extract sql data table. This day I tried to built a window panel box to execute the same sql data table function.
The simple idea is to extract sql data table within a period of time, which would be two input variables in the panel box. The "End_Time" can easily use Today() syntax. However, for "Start_Time", I tried to write a script that allow user to input a certain "hour "before End_time that he want to pull the data table.
Unfortunately, this script is not working as expected.
Can any jmp script guru try to correct my script below? I also attached the jmp script I wrote for modification.
Many Thanks,
nw = new window("SQL Data Table Extraction",
Vlistbox(
tb1=textbox("Start_Time: "),
dteb1 = numbereditbox(1),
hlistbox(
text box("Enter the number of hours: "),
hours_teb = text edit box()),
tb2=textbox("End_Time: "),
dteb2 = numbereditbox(1),
),
ok_button = button box("Get Data", << Open Database("DSN=;Description=;UID=;PWD=;APP=;WSID=", sql_statement, Test Data)),
dteb1 << set format(format("m/d/y h:m:s", 23, 0)),
dteb1 << set width(23),
dteb1 << set(today()-EvalExpr((hours_tab)*60*60)),
dteb2 << set format(format("m/d/y h:m:s", 23, 0)),
dteb2 << set(Today()));
sql_statement="SELECT * FROM dbo.TESTCOMPLETE WHERE (dCreated >= '"||Start Date/Time||"') AND (dCreated <='"||End_Date/Time||"')");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Create a date time panel to extract SQL data
Hi Vince,
Thanks for the guidance and patience. Finally I got it work out.
Underneath one is the correct and working version.
- NamesDefaultToHere(1);
- // Written by Vince Faller
- // Makes a calendar come up on a numeditbox (defaults to now)
- // Note, this only works on JMP 11 or above
- dateBox = Function(
- {timething = Today()},
- {newbox},
- newbox = Eval(
- Substitute(
- Name Expr(
- Number Edit Box(
- timething, // Eval(Sub()) because of JMP quirk
- 10, // Just need this because JMP doesn't default a width
- <<Set function(
- Function( {self},
- {},
- If( Is Missing( self << get ),
- self << Set( Eval( DUMMY ) ) // Sets the date to the timething argument
- )
- )
- ),
- << Set Format( Format( "m/d/y h:m:s", 23, 0 ) ); // Makes datetime format for the box (gives calendar)
- )
- ),
- Expr( DUMMY ), timething
- )
- );
- newbox;
- );
- nw =
- New Window( "SQL Data Table Extraction",
- LineUpBox(NCol(2),
- TextBox("Start DateTime"), start = dateBox(Today() - InDays(12)),
- TextBox("End DateTime"), end = dateBox(),
- ButtonBox("Cancel", nw << close window), ButtonBox("Get Data", RunScript)
- ));
- RunScript= Expr(nw<<Close Window;
- sql_statement=evalinsert("SELECT * FROM dbo.TESTCOMPLETE WHERE dCreated >= '^startDT^' AND dCreated <= '^endDT^' ORDER BY dCreated");
- startDT=MDYHMS(start << get);
- endDT=MDYHMS(end<<get);
- Open Database(
- "DSN=;Description=;UID=;PWD=;APP=;WSID=",
- sql_statement,"Test Result"));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Create a date time panel to extract SQL data
i am using the folwing script to exract SQL data table and limit the time in modal
::dbc = my name and login that i insert in different add in, you can use open data base instead
i added botton for 2 diffrent tables (defect and yield)
another filter for paramter (defect type, yield paramter etc.)
my SQL time column is 'dayxxx'
win = New Window("select data"
<< Modal,
Panel Box("Select",
rbox = Radio Box( {"DEFECT", "YIELD"}
)
,Text Box("PARAMETER"),variablebox1 = Text Edit Box()
,Text Box("Insert days"),variablebox2 = Text Edit Box()
);
area1 = rbox <<get;
PARAM = variablebox1 <<get text ;
Days = variablebox2 <<get text ;
table1 = if(
area1 == 1, "defect tablexxx",
area1 == 2, "yield tablexxx"
)
;
/// SQL data selsction ///
dt = Execute SQL(::dbc,
"SELECT * FROM \!"pathxxx\!".\!""||table1||"\!"
WHERE \!"dayxxx\!" > (CURRENT_DATE - "||Days||" DAYS)
AND \!"parameterxxx\!" = '"||PARAM||"'
"
);
dt << Set Name(""||PARAM||" "||days||"");
*i did alot of modifcation to hide my company data base name so i might made some script erros
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Create a date time panel to extract SQL data
Thanks for sharing....guy.yosef
- « Previous
-
- 1
- 2
- Next »