Select Date Range with Calendar BoxesThis JSL function displays a modal dialog containing two calendar boxes. The boxes are linked with JSL so picking a minimum date in the left box grays unavailable dates in the right box, and similar for the other direction.
Linked calendar boxesLinked calendar boxesLinked calendar boxesLinked calendar boxesLinked calendar boxes
The JSL is written as a function you can call with an optional limit on the range of dates (shown in the title bar). The function call returns a list:
{21Aug2019, 26Aug2019}
promptDateRange = Function( {minAllowed = 1jan1001, maxAllowed = 31dec2999},
{roundMidnight, result, startDate, endDate}, // local variables
roundMidnight = Function( {datetime}, // return the date, without the time...which is midnight at the start of a day
As Date( Date MDY( Month( datetime ), Day( datetime ), Year( datetime ) ) )
);
minAllowed = roundMidnight( minAllowed );
maxAllowed = roundMidnight( maxAllowed );
result = New Window( "Select date range between " || Char( minAllowed ) || " and " || Char( maxAllowed ),
modal, // modal: the window must be closed before JMP can continue
// do the validation in OnValidate, NOT OnClose! Doing it in OnClose will prevent canceling, which is Bad!
<<ONVALIDATE> (startDate << getMaxDate),
startDate << date( startDate << getMaxDate )
);
)
)
),
H Center Box( Text Box( "end", <<SETFONTSIZE></SETFONTSIZE></ONVALIDATE>This JSL turns off the time display in the calendar control and removes any seconds after midnight whenever they appear. The JSL also sets a valid range of dates for the left and right controls; picking a date in the left control changes the minimum date in the right control, and similar in the other direction. The today buttons are removed as well. If you try to modify this JSL to support time you'll discover the today buttons don't make the callback and the time they pick is not midnight-rounded like the minimum and maximum date values.
See Also
https://www.jmp.com/support/help/14-2/date-time-functions.shtml

Select a range of dates with a pair of Calendar Boxes.
Re: Select Date Range with Calendar BoxesThank you @Craige_Hales for your answers.
best regards
Re: Select Date Range with Calendar BoxesThank you @Craige_Hales for pointing out the issue with the calendar icons in the filter. The icon should appear any time you hover over the numeric text, giving you the option to choose between the textual-edit or the calendar-edit. This has been fixed for a future release. As you point out, the calendars still work in the current release, but in some cases it does not show the calendar icon to hint at the functionality.
Re: Select Date Range with Calendar BoxesTry something like this if you want to make your own. In addition to calling a function you supply, I also made it initialize the two calendar dates to the range, rather than today, which seems more useful. You could embed the calendars with the report instead of the modal window.
As written below, you can see how setrange(...) just hides and excludes the data you don't want to see. It is not integrated with the local data filter, but works in a similar way.
dt = New Table( "Untitled 3",
Add Rows( 367 ),
New Column( "date", Numeric, "Continuous", Format( "ddMonyyyy", 10 ), Input Format( "ddMonyyyy" ), Formula( 01Jan2020 + In Days( Row() - 1 ) ) ),
New Column( "value", Numeric, "Continuous", Format( "Best", 12 ), Formula( Random Uniform() ) )
);
gb = dt << Graph Builder(
Size( 531, 456 ),
Show Control Panel( 0 ),
Variables( X( :date ), Y( :value ) ),
Elements( Points( X, Y, Legend( 3 ) ), Line Of Fit( X, Y, Legend( 5 ) ) )
);
wait(0);
setrange=function({low,high},
dt<<SELECT hidden=""> (startDate << getMaxDate),
startDate << date( startDate << getMaxDate )
);
setrange(roundMidnight( startDate << getDate ),roundMidnight( endDate << getDate )); // callback added
)
)
),
H Center Box( Text Box( "end", <<SETFONTSIZE></SETFONTSIZE></SELECT>Re: Select Date Range with Calendar Boxestoo bad, I thought I could use the calendar boxes as a filter instead of having a filter for every type of duration (month, week, year, ..).
thank you for your reply.
all the best !
Re: Select Date Range with Calendar BoxesI don't think so. User defined selectors might be a feature request.
You should be able to get the range slider, but it won't give single-day accuracy over a large date range.
drag the two selector controlsdrag the two selector controlsdrag the two selector controlsdrag the two selector controlsdrag the two selector controls
The calendars are already there, one at a time, and very hard to discover. If you hover over the blue line, the icon sometimes shows where you need to click. When you move to click the icon, it vanishes, but you can still click where it appeared! The cursor also changes to a pointing finger when you move it over the left part of the date. (JMP 15. 16 may be better.) @XanGregg @danschikore @Audrey_Shull
Re: Select Date Range with Calendar BoxesHi,
I would like to use this script to replace a local data filter applied for a graph.
the local data filter has 3 choices: year, month and date.
with 2 calendars, it will be more simple.
is it possible to include it in a local data filter?
best regards