cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
RA899
Level III

prompt the user to choose a certain date and then use it for the local data filter [using JSL]

Hi, 

I have a date column in the mmddyyyy format. I need to print it out to the user to choose from and then use a local data filter to filter the selected dates in Graph builder. 

 

The issue I'm having is that when I try to print the data to the user, it shows it as a long integer that I can't understand. Any suggestions is appreciated. 

 

I have attached a picture of the date column from the data table. 

RA899_1-1709347479303.png

 

RA899_0-1709347435455.png

 

 	  


nw = New Window ( " ",<<Modal, Table Box( String Col Box( "Select date(s)", words (char(dateList), "," ) ), nb = Number Col Edit Box( "", dateValuesIndex, dateOption = nb << get as matrix; ) ), bb = Button Box( "OK", dateOption = nb << get as matrix ),// Button Box( "Cancel" ) );
1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: prompt the user to choose a certain date and then use it for the local data filter [using JSL]

Here's how I would do it:

dt = New Table( "datetbl", Add Rows( 6 ),
	New Column( "My Date", Numeric, "Continuous", Format( "ddMonyyyy", 12 ),
		Input Format( "ddMonyyyy" ),
		Set Values( [3786912000, 3788035200, 3788985600, 3790800000, 3792009600, 3792268800] ) )
);

date_list = dt:my date << get values;
cdate_list = {};
// Convert dates to character strings
for (i = 1, i <= nitems(date_list), i++,
	cdate_list[i] = format(date_list[i], "ddMonyyyy");
);

nw = new window("Test Dates", << modal,
	lineup = Lineup Box( N Col( 2 ),
		textbox("Select start date: "),
		date1_lb = combo box(cdate_list),
		textbox("Select end date: "),
		date2_lb = combo box(cdate_list),
	),
	ok_btn = button box("OK",
		start_date = date1_lb << get selected;
		end_date   = date2_lb << get selected;
	)
);
// Convert character dates back to real dates
start_dt = informat(start_date, "ddMonyyyy");
end_dt   = informat(end_date, "ddMonyyyy");

pmroz_0-1709562884011.pngpmroz_1-1709562930320.png

 

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: prompt the user to choose a certain date and then use it for the local data filter [using JSL]

I suggest that you look into using a Calendar Box() for the input of the date.  See the documentation and examples in the Scripting Index.

Jim
RA899
Level III

Re: prompt the user to choose a certain date and then use it for the local data filter [using JSL]

Thank you @txnelson  for the suggestion. I looked it up and I think it is a good option for my application. The issue I'm having is that the date(s) I'm trying to make the user choose from, might not be sequential. It might be two different days (1st and 15th of the month). The function allows a range between these dates to choose from where I only want the user to choose from these two dates only. The other issue is that it might be more than two days, I might be N number of different dates. I tried think of a solution, but the function could work for two distinguished dates, but not sure how to make it general for N number of date(s). 

 

Do you have any suggestions @txnelson . Thank you so much ! 

 

 

 

 

 

 

txnelson
Super User

Re: prompt the user to choose a certain date and then use it for the local data filter [using JSL]

Do you have a way to determine what all possible dates they could choose from?

Jim
pmroz
Super User

Re: prompt the user to choose a certain date and then use it for the local data filter [using JSL]

Here's how I would do it:

dt = New Table( "datetbl", Add Rows( 6 ),
	New Column( "My Date", Numeric, "Continuous", Format( "ddMonyyyy", 12 ),
		Input Format( "ddMonyyyy" ),
		Set Values( [3786912000, 3788035200, 3788985600, 3790800000, 3792009600, 3792268800] ) )
);

date_list = dt:my date << get values;
cdate_list = {};
// Convert dates to character strings
for (i = 1, i <= nitems(date_list), i++,
	cdate_list[i] = format(date_list[i], "ddMonyyyy");
);

nw = new window("Test Dates", << modal,
	lineup = Lineup Box( N Col( 2 ),
		textbox("Select start date: "),
		date1_lb = combo box(cdate_list),
		textbox("Select end date: "),
		date2_lb = combo box(cdate_list),
	),
	ok_btn = button box("OK",
		start_date = date1_lb << get selected;
		end_date   = date2_lb << get selected;
	)
);
// Convert character dates back to real dates
start_dt = informat(start_date, "ddMonyyyy");
end_dt   = informat(end_date, "ddMonyyyy");

pmroz_0-1709562884011.pngpmroz_1-1709562930320.png