cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

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

How to set default date interval in a date picker script ?

I want to set default dates in the the following date picker script, FROM 6 months back TO today.

What do I need to add or modify in the script below?

Names Default To Here( 1 );
clear log ();

New Window( "Query Date (last 6 months selected by default)",
	<<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-dd" ), 1, "T", " " );
edt = Munger( Format Date( ed, "yyyy-mm-dd" ), 1, "T", " " ); 


Show( sdt, edt );
When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to set default date interval in a date picker script ?

Modify your start date to be something else than current date, date increment should work nicely here

Names Default To Here(1);
Clear Log();

New Window("Query Date (last 6 months selected by default)",
	<<Modal,
	end_date = Today();
	start_date = Date Increment(end_date, "month", -6, "actual");
	
	H List Box(
		Text Box("From:"),
		scal = Number Edit Box(
			start_date,
			<<Set Format(Format("yyyy-mm-dd")),
			<<SetFunction(Function({this}, start_date = scal << Get)),
			<<Set Show Spin Box(1)
		),
		Spacer Box(Size(20, 20)),
		Text Box("To:"),
		ecal = Number Edit Box(
			end_date,
			<<Set Format(Format("yyyy-mm-dd")),
			<<SetFunction(Function({this}, end_date = ecal << Get)),
			<<Set Show Spin Box(1)
		),

	);
);
-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: How to set default date interval in a date picker script ?

Modify your start date to be something else than current date, date increment should work nicely here

Names Default To Here(1);
Clear Log();

New Window("Query Date (last 6 months selected by default)",
	<<Modal,
	end_date = Today();
	start_date = Date Increment(end_date, "month", -6, "actual");
	
	H List Box(
		Text Box("From:"),
		scal = Number Edit Box(
			start_date,
			<<Set Format(Format("yyyy-mm-dd")),
			<<SetFunction(Function({this}, start_date = scal << Get)),
			<<Set Show Spin Box(1)
		),
		Spacer Box(Size(20, 20)),
		Text Box("To:"),
		ecal = Number Edit Box(
			end_date,
			<<Set Format(Format("yyyy-mm-dd")),
			<<SetFunction(Function({this}, end_date = ecal << Get)),
			<<Set Show Spin Box(1)
		),

	);
);
-Jarmo

Recommended Articles