cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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

Recommended Articles