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 Automatic calendar for generated date DateFormat Automatic format used to display date DateGranularity Automatic calendar granularity for generated date Method Automatic midpoint detection method TimeSystem Automatic time system being used TimeZone Automatic time 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 allBasic Examples (4)
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:
Options (9)
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:
Applications (1)
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:
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