MidDate

MidDate[datespec]

gives the midpoint instant of a date or list of dates datespec.

MidDate[datespec,gran]

gives the midpoint date object with granularity gran.

MidDate[datespec,gran,x]

gives the date that is the fraction x between the beginning and end of datespec.

Details and Options

  • MidDate gives the date that is midway through a given date or list of dates.
  • Possible forms of datespec in MidDate[datespec,] include:
  • DateObject[]mid date of a date object of any granularity
    TimeObject[]mid time of a time object of any granularity
    DateInterval[]mid date of a date interval
    {d1,d2,}mid date of a list of dates, times and intervals
    TimeSeries[]mid date of the times of a time series
    EventSeries[]mid date of the times of an event series
    TemporalData[]mid date of the times of temporal data
  • MidDate[(d1,d2,}] gives the midpoint instant based on the sum of probability density functions for a uniform distribution of the di dates.
  • MidDate takes the following options:
  • CalendarType Automaticcalendar for generated date
    DateFormat Automaticformat used to display date
    DateGranularityAutomaticcalendar granularity for generated date
    Method Automaticmidpoint detection method
    TimeSystem Automatictime system being used
    TimeZone Automatictime zone being used
  • With MidDate[{d1,d2,},Methodmethod], the Method option value method determines how midpoint dates are calculated for the di dates. Possible Method values include:
  • "GranularMean"mean weighted by granularity length (default)
    "GranularMedian"median weighted by granularity length
    "WeightedMean"mean weighted by full duration of each date
    "UnionedMean"mean of the unioned region of all dates
    "MidpointMean"mean of midpoints
    "MidpointMedian"median of midpoints
    "BoundsMean"mean of the date bounds

Examples

open allclose all

Basic Examples  (4)

Get the midpoint instant for a month-granular date:

Find the day that falls in the middle of a year:

Find the hour that is 2/3 of the way through a given week:

Find the mid date of three instants in the year 2024:

Scope  (7)

For list inputs, the midpoint is taken based on the implicit interval for each date in the list:

The full time interval for each date is taken into account:

For mid dates with coarse granularity, the date given corresponds to the instance that encompasses the midpoint, even if it begins before the first date:

Get the mid date for an EventSeries:

Get the mid date from a Databin:

Find the mid date for an Association:

Find the mid time of five times today:

Find the midpoint instant of three date intervals:

Options  (9)

CalendarType  (1)

Return the midpoint date in the Japanese calendar:

DateFormat  (1)

Return the midpoint date in an "ISODateTime" format:

Method  (5)

The default midpoint detection method ("GranularMean") takes into account granularity length when selecting a midpoint:

This means a one-week period is weighted equally whether it appears as a single "Week" date or as a sequence of seven "Day" dates:

The method "WeightedMean" takes into account the full length of each date, not just its granularity:

The method "MidpointMedian" gives equal weight to all dates, regardless of granularity:

The method "BoundsMean" considers only the outer date bounds of the dates:

Some midpoint detection methods weight for granularity, while others treat all dates as equally weighted:

With only two dates given, "Weighted" methods will account for granularity and be pulled toward coarser granularity dates:

With the coarser granularity broken up into individual dates, the "Weighted" methods remain consistent:

Midpoint methods weight all dates equally and thus do not account for difference in granularity:

If broken into individual days, these midpoint methods will be pulled to the right:

"WeightedMean" and "UnionedMean" both account for the full duration of dates, but "WeightedMean" will account for overlapping intervals, while "UnionedMean" will flatten all intervals:

TimeSystem  (1)

Return the midpoint date in the "TAI" time system:

TimeZone  (1)

Return the midpoint date in GMT:

Applications  (1)

Find the release dates of all James Bond movies:

Find the mid date of those release dates:

The midpoint of the bounds was six years later, reflecting an accumulation of releases in the early years:

Properties & Relations  (1)

Mean, Median, Quantile and CentralFeature all use different methods to find central dates:

Possible Issues  (1)

A list of numbers is interpreted by MidDate as a list of absolute times, not as a single date list:

Wolfram Research (2025), MidDate, Wolfram Language function, https://reference.wolfram.com/language/ref/MidDate.html.

Text

Wolfram Research (2025), MidDate, Wolfram Language function, https://reference.wolfram.com/language/ref/MidDate.html.

CMS

Wolfram Language. 2025. "MidDate." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MidDate.html.

APA

Wolfram Language. (2025). MidDate. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MidDate.html

BibTeX

@misc{reference.wolfram_2024_middate, author="Wolfram Research", title="{MidDate}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/MidDate.html}", note=[Accessed: 15-January-2025 ]}

BibLaTeX

@online{reference.wolfram_2024_middate, organization={Wolfram Research}, title={MidDate}, year={2025}, url={https://reference.wolfram.com/language/ref/MidDate.html}, note=[Accessed: 15-January-2025 ]}