cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-216467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EAdd%20a%20new%20window%20for%20Start%20%26amp%3B%20End%20Calendar%20date%20selection%20box%2F%20date%20entry%20box%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-216467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHi%20JMP%20community%2C%20I%20usually%20use%20jmp%20preselected%20and%20plot%20graphs%20need%20a%20help%20to%20add%20selection%20date%20amend%20for%20my%20script%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20per%20below%2C%20once%20I%20call%20out%20database%2C%20I%20have%20to%20amend%20the%20dates%20for%20start%20%26amp%3B%20end%20in%20order%20to%20query%20needed%20data%20on%20input%20dates.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open%20Database(%0A%20%22DSN%3Dxxx%20%3BDescription%3Dyyy%3BUID%3Dzzz%3BPWD%3Dzzz%3BAPP%3DJMP%3BDATABASE%3DMATS%3B%22%2C%0A%20%22SELECT%20pen_parametric.pn_id%2C%20pen_parametric.equiplk_ky%2C%20parametric_dlk.paramlk_ky%2C%0AFROM%20MATS.parametric_dlk%20parametric_dlk%2C%20MATS.pen_parametric%20pen_parametric%0AWHERE%20parametric_dlk.paramlk_ky%20%3D%20parametric_ref_llk.paramlk_ky%20AND%20parametric_dlk.paramlk_ky%20%3D%20pen_parametric.paramlk_ky%20AND%20((pen_parametric.part_dm%20Between%20%7Bts%20'2019-07-01%2000%3A00%3A00'%7D%20And%20%7Bts%20'2019-07-02%2000%3A00%3A00'%7D))%22%0A)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20Set%20Name(%20%22Data01%22%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%2C%20for%26nbsp%3B%3CSTRONG%3E(Between%20%7Bts%20'%3CFONT%20color%3D%22%230000FF%22%3E%3CEM%3E2019-07-01%2000%3A00%3A00%3C%2FEM%3E%3C%2FFONT%3E'%7D%20And%20%7Bts%20'%3CFONT%20color%3D%22%2399CC00%22%3E%3CEM%3E2019-07-02%2000%3A00%3A00%3C%2FEM%3E%3C%2FFONT%3E'%7D)%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIs%20it%20possible%20for%20adding%20a%20script%20box%20that%20prompt%20up%20new%20window%20calendar%20box%20for%20selection%20of%20the%20calendar%20as%20per%20formatted%20date%20above%20so%20can%20replace%20the%20date%20to%20the%20ones%20i%20want%2Fselect%20and%20then%20run%20the%20script%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThank%20you%20in%20advance!%3C%2FP%3E%0A%3CP%3EBR%2C%20Otis%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-216986%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Add%20a%20new%20window%20for%20Start%20%26amp%3B%20End%20Calendar%20date%20selection%20box%2F%20date%20entry%20box%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-216986%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDan%2C%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F4587%22%20target%3D%22_blank%22%3E%40danschikore%3C%2FA%3E%26nbsp%3B%2C%20thank%20you.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20too%20like%20the%20date%20formatted%20NumberEditBox().%20I%20was%20going%20to%20post%20an%20alternate%20script%20that%20produces%20the%20dialog%20shown%20below.%20However%2C%20I%20thought%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F15309%22%20target%3D%22_blank%22%3E%40OtisZeca%3C%2FA%3E%26nbsp%3Bmight%20be%20new%20to%20JSL.%26nbsp%3B%20Very%20useful%20options%20of%20the%20NumberEditbox()%20includes%2C%20setting%20a%20minimum%2C%20a%20maximum%20and%20specifying%20integer%20only.%26nbsp%3B%20The%20attached%20script%20uses%20a%20function%20to%20create%20a%20bounded%20integer%20number%20edit%20box%20that%20returns%20the%20value%20to%20a%20user%20specified%20variable%2C%20which%20is%20vauable%20for%20non-Modal%20dialogs.%20I%20am%20posting%20it%20for%20the%20blog%2C%20since%20I%20know%20you%20don't%20need%20an%20example.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20612px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20612px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20612px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F18271iA02BC9F1B69317FD%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-216890%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Add%20a%20new%20window%20for%20Start%20%26amp%3B%20End%20Calendar%20date%20selection%20box%2F%20date%20entry%20box%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-216890%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHere's%20a%20modified%20version%20of%20Georgia's%20script%20that%20uses%20Number%20Edit%20Box%20instead%20of%20directly%20using%20the%20Calendar%20Box.%26nbsp%3B%20Number%20Edit%20Box%20has%20a%20popup%20version%20of%20the%20calendar%20build-in%20if%20the%20numeric%20format%20is%20set%20to%20a%20date.%26nbsp%3B%20I%20set%20the%20format%20to%20only%20include%20the%20day%2C%20but%20you%20can%20include%20time-of-day%20as%20well%20if%20you%20need%20that%20level%20of%20granularity.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22NumEditCalendar.png%22%20style%3D%22width%3A%20309px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22NumEditCalendar.png%22%20style%3D%22width%3A%20309px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22NumEditCalendar.png%22%20style%3D%22width%3A%20309px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F18268i834A3461698D653E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22NumEditCalendar.png%22%20alt%3D%22NumEditCalendar.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0A%0Atmpstr%20%3D%0A%22SELECT%20pen_parametric.pn_id%2C%20pen_parametric.equiplk_ky%2C%20parametric_dlk.paramlk_ky%2C%0AFROM%20MATS.parametric_dlk%20parametric_dlk%2C%20MATS.pen_parametric%20pen_parametric%0AWHERE%20parametric_dlk.paramlk_ky%20%3D%20parametric_ref_llk.paramlk_ky%20%0A%20%20AND%20parametric_dlk.paramlk_ky%20%3D%20pen_parametric.paramlk_ky%20%0A%20%20%20AND%20((pen_parametric.part_dm%20Between%20%7Bts%20'%5Esdt%5E'%7D%20And%20%7Bts%20'%5Eedt%5E'%7D))%22%3B%0A%0ANew%20Window(%20%22Query%20Date%22%2C%0A%20%26lt%3B%3CMODAL%3E%3C%2FMODAL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-216850%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Add%20a%20new%20window%20for%20Start%20%26amp%3B%20End%20Calendar%20date%20selection%20box%2F%20date%20entry%20box%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-216850%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Eahh%20icic..%20thanks%20for%20your%20help!%26nbsp%3B%3C%2FP%3E%3CP%3Eneed%20more%20practice%20understanding%20what%20you've%20written.%20thank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-216479%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Add%20a%20new%20window%20for%20Start%20%26amp%3B%20End%20Calendar%20date%20selection%20box%2F%20date%20entry%20box%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-216479%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F15309%22%20target%3D%22_blank%22%3E%40OtisZeca%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20multiple%20methods%20to%20do%20this.%20Here%20is%20one%20example%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20663px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20663px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20663px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F18199iA9E30F992F39B5C9%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0A%0Atmpstr%20%3D%20%22SELECT%20pen_parametric.pn_id%2C%20pen_parametric.equiplk_ky%2C%20parametric_dlk.paramlk_ky%2C%0AFROM%20MATS.parametric_dlk%20parametric_dlk%2C%20MATS.pen_parametric%20pen_parametric%0AWHERE%20parametric_dlk.paramlk_ky%20%3D%20parametric_ref_llk.paramlk_ky%20%0A%20%20AND%20parametric_dlk.paramlk_ky%20%3D%20pen_parametric.paramlk_ky%20%0A%20%20%20AND%20((pen_parametric.part_dm%20Between%20%7Bts%20'%5Esdt%5E'%7D%20And%20%7Bts%20'%5Eedt%5E'%7D))%22%0A%3B%0A%0ANew%20Window(%20%22Query%20Date%22%2C%20%26lt%3B%3CMODAL%3E%3C%2FMODAL%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
OtisZeca
Level I

Add a new window for Start & End Calendar date selection box/ date entry box

Hi JMP community, I usually use jmp preselected and plot graphs need a help to add selection date amend for my script below.

 

As per below, once I call out database, I have to amend the dates for start & end in order to query needed data on input dates.

 

dt = Open Database(
	"DSN=xxx ;Description=yyy;UID=zzz;PWD=zzz;APP=JMP;DATABASE=MATS;",
	"SELECT pen_parametric.pn_id, pen_parametric.equiplk_ky, parametric_dlk.paramlk_ky,
FROM MATS.parametric_dlk parametric_dlk, MATS.pen_parametric pen_parametric
WHERE parametric_dlk.paramlk_ky = parametric_ref_llk.paramlk_ky AND parametric_dlk.paramlk_ky = pen_parametric.paramlk_ky AND ((pen_parametric.part_dm Between {ts '2019-07-01 00:00:00'} And {ts '2019-07-02 00:00:00'}))"
);

dt << Set Name( "Data01" );

 

So, for (Between {ts '2019-07-01 00:00:00'} And {ts '2019-07-02 00:00:00'})

Is it possible for adding a script box that prompt up new window calendar box for selection of the calendar as per formatted date above so can replace the date to the ones i want/select and then run the script?

 

Thank you in advance!

BR, Otis

2 ACCEPTED SOLUTIONS

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Add a new window for Start & End Calendar date selection box/ date entry box

@OtisZeca,

 

There are multiple methods to do this. Here is one example 

 

image.png

Names Default To Here( 1 );

tmpstr = "SELECT pen_parametric.pn_id, pen_parametric.equiplk_ky, parametric_dlk.paramlk_ky,
FROM MATS.parametric_dlk parametric_dlk, MATS.pen_parametric pen_parametric
WHERE parametric_dlk.paramlk_ky = parametric_ref_llk.paramlk_ky 
  AND parametric_dlk.paramlk_ky = pen_parametric.paramlk_ky 
   AND ((pen_parametric.part_dm Between {ts '^sdt^'} And {ts '^edt^'}))"
;

New Window( "Query Date", <<Modal,

sd=Today();
ed=Today();
 HListBox(
    PanelBox( "From Time",
      scal = Calendar Box(, SetFunction(Function({this}, sd=scal<< Get Date) ))
    ),
    spacerbox(Size(20,20)),
    PanelBox( "To Time",
    ecal = Calendar Box(, SetFunction(Function({this}, ed=ecal<< Get Date) ))
    )
));

sdt = Munger(Format Date(sd, "yyyy-mm-ddThh:mm:ss"), 1, "T", " "); 
edt = Munger(Format Date(ed, "yyyy-mm-ddThh:mm:ss"), 1, "T", " "); 


show(sdt, edt);
 
qstring = EvalInsert(tmpstr);
show(qstring);  //see log

//then run the line below
//dt = Open Database("DSN=xxx ;Description=yyy;UID=zzz;PWD=zzz;APP=JMP;DATABASE=MATS;", qstring);

 

View solution in original post

Re: Add a new window for Start & End Calendar date selection box/ date entry box

Here's a modified version of Georgia's script that uses Number Edit Box instead of directly using the Calendar Box.  Number Edit Box has a popup version of the calendar build-in if the numeric format is set to a date.  I set the format to only include the day, but you can include time-of-day as well if you need that level of granularity.

 

NumEditCalendar.png

 

Names Default To Here( 1 );

tmpstr =
"SELECT pen_parametric.pn_id, pen_parametric.equiplk_ky, parametric_dlk.paramlk_ky,
FROM MATS.parametric_dlk parametric_dlk, MATS.pen_parametric pen_parametric
WHERE parametric_dlk.paramlk_ky = parametric_ref_llk.paramlk_ky 
  AND parametric_dlk.paramlk_ky = pen_parametric.paramlk_ky 
   AND ((pen_parametric.part_dm Between {ts '^sdt^'} And {ts '^edt^'}))";

New Window( "Query Date",
	<<Modal, 
	sd = Today();
	ed = Today();
	H List Box(
		Text Box( "From:" ),
		scal = Number Edit Box( sd, <<Set Format( Format( "yyyy-mm-dd" ) ), <<SetFunction( Function( {this}, sd = scal << Get ) ), <<Set Show Spin Box(1) ),
		Spacer Box( Size( 20, 20 ) ),
		Text Box( "To:" ),
		ecal = Number Edit Box( ed, <<Set Format( Format( "yyyy-mm-dd" ) ), <<SetFunction( Function( {this}, ed = ecal << Get ) ), <<Set Show Spin Box(1) ),
	);
);

sdt = Munger( Format Date( sd, "yyyy-mm-ddThh:mm:ss" ), 1, "T", " " );
edt = Munger( Format Date( ed, "yyyy-mm-ddThh:mm:ss" ), 1, "T", " " ); 


Show( sdt, edt );
 
qstring = Eval Insert( tmpstr );
Show( qstring );  //see log

View solution in original post

4 REPLIES 4
gzmorgan0
Super User (Alumni)

Re: Add a new window for Start & End Calendar date selection box/ date entry box

@OtisZeca,

 

There are multiple methods to do this. Here is one example 

 

image.png

Names Default To Here( 1 );

tmpstr = "SELECT pen_parametric.pn_id, pen_parametric.equiplk_ky, parametric_dlk.paramlk_ky,
FROM MATS.parametric_dlk parametric_dlk, MATS.pen_parametric pen_parametric
WHERE parametric_dlk.paramlk_ky = parametric_ref_llk.paramlk_ky 
  AND parametric_dlk.paramlk_ky = pen_parametric.paramlk_ky 
   AND ((pen_parametric.part_dm Between {ts '^sdt^'} And {ts '^edt^'}))"
;

New Window( "Query Date", <<Modal,

sd=Today();
ed=Today();
 HListBox(
    PanelBox( "From Time",
      scal = Calendar Box(, SetFunction(Function({this}, sd=scal<< Get Date) ))
    ),
    spacerbox(Size(20,20)),
    PanelBox( "To Time",
    ecal = Calendar Box(, SetFunction(Function({this}, ed=ecal<< Get Date) ))
    )
));

sdt = Munger(Format Date(sd, "yyyy-mm-ddThh:mm:ss"), 1, "T", " "); 
edt = Munger(Format Date(ed, "yyyy-mm-ddThh:mm:ss"), 1, "T", " "); 


show(sdt, edt);
 
qstring = EvalInsert(tmpstr);
show(qstring);  //see log

//then run the line below
//dt = Open Database("DSN=xxx ;Description=yyy;UID=zzz;PWD=zzz;APP=JMP;DATABASE=MATS;", qstring);

 

OtisZeca
Level I

Re: Add a new window for Start & End Calendar date selection box/ date entry box

ahh icic.. thanks for your help! 

need more practice understanding what you've written. thank you!

Re: Add a new window for Start & End Calendar date selection box/ date entry box

Here's a modified version of Georgia's script that uses Number Edit Box instead of directly using the Calendar Box.  Number Edit Box has a popup version of the calendar build-in if the numeric format is set to a date.  I set the format to only include the day, but you can include time-of-day as well if you need that level of granularity.

 

NumEditCalendar.png

 

Names Default To Here( 1 );

tmpstr =
"SELECT pen_parametric.pn_id, pen_parametric.equiplk_ky, parametric_dlk.paramlk_ky,
FROM MATS.parametric_dlk parametric_dlk, MATS.pen_parametric pen_parametric
WHERE parametric_dlk.paramlk_ky = parametric_ref_llk.paramlk_ky 
  AND parametric_dlk.paramlk_ky = pen_parametric.paramlk_ky 
   AND ((pen_parametric.part_dm Between {ts '^sdt^'} And {ts '^edt^'}))";

New Window( "Query Date",
	<<Modal, 
	sd = Today();
	ed = Today();
	H List Box(
		Text Box( "From:" ),
		scal = Number Edit Box( sd, <<Set Format( Format( "yyyy-mm-dd" ) ), <<SetFunction( Function( {this}, sd = scal << Get ) ), <<Set Show Spin Box(1) ),
		Spacer Box( Size( 20, 20 ) ),
		Text Box( "To:" ),
		ecal = Number Edit Box( ed, <<Set Format( Format( "yyyy-mm-dd" ) ), <<SetFunction( Function( {this}, ed = ecal << Get ) ), <<Set Show Spin Box(1) ),
	);
);

sdt = Munger( Format Date( sd, "yyyy-mm-ddThh:mm:ss" ), 1, "T", " " );
edt = Munger( Format Date( ed, "yyyy-mm-ddThh:mm:ss" ), 1, "T", " " ); 


Show( sdt, edt );
 
qstring = Eval Insert( tmpstr );
Show( qstring );  //see log
gzmorgan0
Super User (Alumni)

Re: Add a new window for Start & End Calendar date selection box/ date entry box

Dan, @danschikore , thank you.

 

I too like the date formatted NumberEditBox(). I was going to post an alternate script that produces the dialog shown below. However, I thought @OtisZeca might be new to JSL.  Very useful options of the NumberEditbox() includes, setting a minimum, a maximum and specifying integer only.  The attached script uses a function to create a bounded integer number edit box that returns the value to a user specified variable, which is vauable for non-Modal dialogs. I am posting it for the blog, since I know you don't need an example.

 

image.png

Recommended Articles