is an option that specifies how input dates should be interpreted in objects like TimeSeries or EventSeries and date visualization functions like DateListPlot or DateHistogram.
DateFunction
is an option that specifies how input dates should be interpreted in objects like TimeSeries or EventSeries and date visualization functions like DateListPlot or DateHistogram.
Details
- DateFunction is typically used to convert input dates into a specific format or to resolve possible ambiguities in the input.
- A setting such as DateFunction->(DateList[#,{"e1",…}]&) specifies that a sequence of elements "ei" should be extracted from each date. »
- Typical default values for the DateFunction option include Automatic and Identity.
Examples
open all close allBasic Examples (3)
Prepend a year to create dates from {month,day} lists:
data = {{{10, 1}, 8}, {{10, 10}, 10}, {{10, 20}, 12}, {{10, 24}, 14}, {{11, 5}, 15}, {{11, 15}, 20}};DateListPlot[data, DateFunction :> (Join[{2006}, #]&)]Interpret dates indexed by a week number:
data = Table[{i, Sin[i / Pi]}, {i, 50}];DateListPlot[data, DateFunction :> (DateList[{2006, 1, 1 + # * 7}]&)]By default, the date granularity of a time series is inferred from the input timestamps:
TimeSeries[Range[3], {Today}]Normal[%]Use DateFunction to select a different granularity:
TimeSeries[Range[3], {Today}, DateFunction -> Function[DateObject[#, "Year"]]]Normal[%]Scope (2)
Define functions for interpreting ambiguous date strings for DateListPlot:
data = {{"06/01/06", 8}, {"07/01/06", 10}, {"08/01/06", 12}, {"09/01/06", 14}, {"10/01/06", 15}, {"11/01/06", 20}};DateListPlot[data, DateFunction :> (DateList[{#, {"Month", "Day", "YearShort"}}]&)]DateListPlot[data, DateFunction :> (DateList[{#, {"Day", "Month", "YearShort"}}]&)]DateListPlot[data, DateFunction :> (DateList[{#, {"YearShort", "Month", "Day"}}]&)]Take a list of date-value pairs with ambiguous dates:
data = {{"2006 12-1", 8}, {"2006 12-2", 10}, {"2006 12-3", 12}, {"2006 12-4", 14}, {"2006 12-5", 15}, {"2006 12-6", 20}};DateObject[data[[1, 1]]]Specify a year-month-day interpretation:
EventSeries[data, DateFunction :> (DateObject[{#, {"Year", "Month", "Day"}}, "Day"]&)]Normal[%]Specify the alternative year-day-month interpretation:
EventSeries[data, DateFunction :> (DateObject[{#, {"Year", "Day", "Month"}}, "Day"]&)]Normal[%]Related Guides
History
Text
Wolfram Research (2007), DateFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/DateFunction.html.
CMS
Wolfram Language. 2007. "DateFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DateFunction.html.
APA
Wolfram Language. (2007). DateFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DateFunction.html
BibTeX
@misc{reference.wolfram_2026_datefunction, author="Wolfram Research", title="{DateFunction}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/DateFunction.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_datefunction, organization={Wolfram Research}, title={DateFunction}, year={2007}, url={https://reference.wolfram.com/language/ref/DateFunction.html}, note=[Accessed: 13-June-2026]}