DateWithinQ
DateWithinQ[date1,date2]
更多信息
- 在 DateWithinQ[date1, date2] 中,date1 和 date2 应被指定为任意日历粒度的 DateObject 表达式.
- DateWithinQ 的两个参数都接受日期列表,实际上是对输入列表调用 Outer.
- 只有当 date2 完全被包含在 date1 所表示的时间段中时,DateWithinQ 才返回 True.
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (3)
DateWithinQ[{Yesterday, Today, Tomorrow}, Now]DateWithinQ[DateObject[{2022}, "Year"], {DateObject[{2022, 5, 9}, "Day"], DateObject[{2021, 8, 4}, "Day"], DateObject[{2022, 4}, "Month"]}]DateWithinQ[{DateObject[{2022}, "Year"], DateObject[{2021, 12}, "Month"]}, {DateObject[{2022, 6, 17}, "Day"], DateObject[{2021, 12, 25}, "Day"], Entity["Country", "SouthKorea"][EntityProperty["Country", "IndependenceDate"]]}]属性和关系 (3)
只有当 date2 完全被包含在 date1 中时,DateWithinQ 才返回 True:
DateWithinQ[DateObject[{2022, 1}, "Month"], DateObject[{2022, 1, 31}, "Week"]]可用 DateOverlapsQ 来检测部分包含的情况:
DateOverlapsQ[DateObject[{2022, 1}, "Month"], DateObject[{2022, 1, 31}, "Week"]]如果一个日期对象被包含在另一个日期对象内,它们的差将是以最大日历粒度计算得出的零:
DateWithinQ[DateObject[{2022}, "Year"], DateObject[{2022, 5, 9}, "Day"]]DateObject[{2022, 5, 9}, "Day"] - DateObject[{2022}, "Year"]如果一个日期对象被包含在另一个日期对象内,因为彼此重合,所以无法对它们进行比较:
DateWithinQ[DateObject[{2023, 8}, "Month"], DateObject[{2023, 8, 4}, "Day"]]DateObject[{2023, 8}, "Month"] < DateObject[{2023, 8, 4}, "Day"]文本
Wolfram Research (2017),DateWithinQ,Wolfram 语言函数,https://reference.wolfram.com/language/ref/DateWithinQ.html.
CMS
Wolfram 语言. 2017. "DateWithinQ." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/DateWithinQ.html.
APA
Wolfram 语言. (2017). DateWithinQ. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/DateWithinQ.html 年
BibTeX
@misc{reference.wolfram_2026_datewithinq, author="Wolfram Research", title="{DateWithinQ}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/DateWithinQ.html}", note=[Accessed: 13-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_datewithinq, organization={Wolfram Research}, title={DateWithinQ}, year={2017}, url={https://reference.wolfram.com/language/ref/DateWithinQ.html}, note=[Accessed: 13-September-2026]}