returns True if the calendar date date2 is entirely contained within date1, and False otherwise.


  • In DateWithinQ[date1, date2], both date1 and date2 should be specified as DateObject expressions of any calendar granularity.
  • DateWithinQ accepts lists of dates in both arguments, effectively calling Outer on the input lists.
  • DateWithinQ returns True only if date2 falls entirely within the period represented by date1.


open allclose all

Basic Examples  (2)

Now falls within Today:

But it does not fall within Yesterday:

Test whether the current date is within the year 2017:

Scope  (3)

Test whether a date is within several dates:

Test whether several dates are within a given date:

Test for containment of several dates within several other dates:

Properties & Relations  (3)

DateWithinQ will return True only if date2 is entirely contained within date1:

DateOverlapsQ can be used to test for partial containment:

If a date object is within another, their difference will be zero of the largest calendar granularity:

If a date object is within another, they cannot be compared because they overlap:

Introduced in 2017