cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Neo
Neo
Level VI

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