This 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 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},
roundMidnight = Function( {datetime},
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,
<<OnValidate( (startDate << getDate) <= (endDate << getDate) ),
<<OnClose(
startDate = roundMidnight( startDate << getDate );
endDate = roundMidnight( endDate << getDate );
1;
),
<<OnOpen(
(((startDate)[Button Box( 3 )])) << delete;
(((endDate)[Button Box( 3 )])) << delete;
),
H List Box(
V List Box(
startDate = Calendar Box(
<<min date( minAllowed ),
<<max date( maxAllowed ),
<<showTime( 0 ),
<<setfunction(
Function( {this, date},
{},
endDate << mindate( roundMidnight( startDate << getDate ) );
If( roundMidnight( endDate << getDate ) < (endDate << getMinDate),
endDate << date( endDate << getMinDate )
);
startDate << maxdate( roundMidnight( endDate << getDate ) );
)
)
),
H Center Box( Text Box( "begin", <<setFontSize( 20 ) ) )
),
Spacer Box( size( 50, 1 ) ),
V List Box(
endDate = Calendar Box(
<<min date( minAllowed ),
<<max date( maxAllowed ),
<<showtime( 0 ),
<<setfunction(
Function( {this, date},
{},
endDate << mindate( roundMidnight( startDate << getDate ) );
startDate << maxdate( roundMidnight( endDate << getDate ) );
If( roundMidnight( startDate << getDate ) > (startDate << getMaxDate),
startDate << date( startDate << getMaxDate )
);
)
)
),
H Center Box( Text Box( "end", <<setFontSize( 20 ) ) )
)
)
);
If( result["Button"] == 1,
Eval List( {startDate, endDate} )
,
{., .}
);
);
Write( promptDateRange( Today() - In Days( 5 ), Today() + In Days( 5 ) ) );
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