使用日历框选择日期范围此 JSL 函数显示一个包含两个日历框的模式对话框。 这些框与 JSL 链接,因此在左侧框中选择最短日期会使右侧框中的不可用日期变灰,其他方向也类似。
Linked calendar boxesLinked calendar boxesLinked calendar boxesLinked calendar boxes链接的日历框
JSL 被编写为一个函数,您可以通过对日期范围(显示在标题栏中)的可选限制来调用。函数调用返回一个列表:
{2019 年 8 月 21 日、2019 年 8 月 26 日}
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>此 JSL 会关闭日历控件中的时间显示,并删除午夜之后出现的任何秒数。 JSL 还为左右控件设置了有效的日期范围;在左侧控件中选择日期会更改右侧控件中的最小日期,反之亦然。 今天的按钮也被删除。 如果您尝试修改此 JSL 以支持时间,您会发现“今天”按钮不会进行回调,并且它们选择的时间不像最小和最大日期值那样是午夜舍入的。
也可以看看
https://www.jmp.com/support/help/14-2/date-time-functions.shtml

使用一对日历框选择日期范围。
回复:使用日历框选择日期范围谢谢@Craige_Hales为您解答。
此致
回复:使用日历框选择日期范围谢谢@Craige_Hales用于指出过滤器中日历图标的问题。每当您将鼠标悬停在数字文本上时,都会出现该图标,让您可以在文本编辑或日历编辑之间进行选择。此问题已在未来版本中修复。正如您所指出的,日历在当前版本中仍然有效,但在某些情况下,它不会显示日历图标来暗示该功能。
回复:使用日历框选择日期范围如果你想自己做的话,试试这样的东西。 除了调用您提供的函数之外,我还让它将两个日历日期初始化为该范围,而不是今天,这似乎更有用。 您可以将日历而不是模式窗口嵌入到报表中。
如下所示,您可以看到如何设置范围(...)只是隐藏并排除您不想看到的数据。 它没有与本地数据过滤器集成,但工作方式类似。
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>回复:使用日历框选择日期范围太糟糕了,我想我可以使用日历框作为过滤器,而不是为每种类型的持续时间(月,周,年,..)设置过滤器。
感谢你的回复。
一切顺利 !
回复:使用日历框选择日期范围我不这么认为。 用户定义的选择器可能是一个功能请求。
您应该能够获得范围滑块,但它不会提供大日期范围内的单日精度。
drag the two selector controlsdrag the two selector controlsdrag the two selector controlsdrag the two selector controls拖动两个选择器控件
日历已经在那里了,一次一张,而且很难找到。 如果将鼠标悬停在蓝线上,图标有时会显示您需要单击的位置。 当您移动并单击该图标时,它会消失,但您仍然可以单击它出现的位置! 当您将光标移到日期的左侧部分时,光标也会变为手指。 (JMP 15. 16 可能更好。) @XanGregg @danschikore @奥黛丽_舒尔
回复:使用日历框选择日期范围你好,
我想使用此脚本来替换应用于图表的本地数据过滤器。
本地数据过滤器有 3 个选择:年、月、日。
有了2个日历,就更简单了。
是否可以将其包含在本地数据过滤器中?
此致