DateRange
Details and Options
- Dates can be specified in the following forms:
-
DateObject[…] date object {y,m,d,h,m,s} precise time {y,m,d} year, month, day {y,m} the first day of the specified month {y} the first day of the first month of the year y "string" date as a string ("Jan. 1, 2022") time absolute time specification - {y,m,d} is taken to be equivalent to {y,m,d,0,0,0} etc.
- Possible increments are denominated in the following calendar steps and day types: "Year", "Quarter", "Month", "Week", "Day", "Hour", "Minute", "Second", "Weekday", "Weekend", Monday through Sunday, "EndOfMonth", "BeginningOfMonth", and "BusinessDay".
- Mixed-radix increments are permitted.
- An increment may be specified using the Quantity framework.
- In DateRange[date1,date2] where date2 is a granular DateObject, range results will include all dates through the end of date2.
- DateRange takes the following option:
-
CalendarType "Gregorian" calendar in which the date parameters have been specified HolidayCalendar {"UnitedStates","Default"} holiday schedule and subspecification for the business day and holiday computations
Examples
open all close allBasic Examples (4)
Give all the dates in a date range:
With[{first = Today}, DateRange[first, DatePlus[first, Quantity[5, "Days"]]]]With[{first = Today}, DateRange[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], {1, "Week"}]]Increment dates by one year, one month, and one day:
With[{first = Yesterday}, DateRange[first, DatePlus[first, {{10, "Year"}, {-1, "Day"}}], {{1, "Year"}, {1, "Month"}, {-1, "Day"}}]]DateRange has constraints similar to Range:
With[{first = Yesterday}, Table[DateRange[first, DatePlus[first, {-1, "Year"}], {i, "Year"}], {i, {-1, 0, 1}}]]Scope (5)
The output is sensitive to the choice of step size:
DateRange[DateObject[{1700, 1, 1}], DateObject[{1900, 1, 1}], {10, "Year"}]DateRange[DateObject[{1700, 1, 1}], DateObject[{1900, 1, 1}], {10 1461 24 3600, "Second"}]Increment can be specified using the quantity framework:
DateRange[DateObject[{2021, 1, 1}], DateObject[{2022}], Quantity[40, "Days"]]DateRange interprets string inputs:
DateRange["dec. 1st, 2021", "2022"]The increment "Week" is equivalent to {1,"Week"}:
DateRange[DateObject[{2021, 1, 1}, "Day"], DateObject[{2021}, "Year"], "Week"]The increment must be net-negative if the endpoints are not in chronological order:
DateRange[DateObject[{2022, 1, 1}], DateObject[{2021}], {{-1, "Month"}, {2.3, "Week"}}]Options (4)
CalendarType (3)
Create a list of Jewish calendar dates:
DateRange[{5779, 8, 13}, {5779, 9, 1}, CalendarType -> "Jewish"]Create a list of consecutive weekly dates in the Jewish calendar:
Short[DateRange[DateObject[{5373, 4, 3}, CalendarType -> "Jewish"], DateObject[{5374, 4, 3}, CalendarType -> "Jewish"], "Week"], 2]Print all dates for the current Islamic year:
CalendarConvert[Today, "Islamic"]Short[DateRange[DateObject[{1434, 1, 1}, CalendarType -> "Islamic"], DateObject[{1435}, CalendarType -> "Islamic"]], 2]HolidayCalendar (1)
Different markets within a country may have different holiday schedules:
CalendarData["UnitedStates"]With[{first = DateObject[{2022, 4, 1}]}, DateRange[first, DatePlus[first, {{1, "Week"}}], "BusinessDay", HolidayCalendar -> {"UnitedStates", "NYSE"}]]With[{first = DateObject[{2022, 4, 1}]}, DateRange[first, DatePlus[first, {{1, "Week"}}], "BusinessDay"]]See Also
Related Guides
History
Introduced in 2012 (9.0) | Updated in 2014 (10.0) ▪ 2018 (11.3) ▪ 2023 (13.3)
Text
Wolfram Research (2012), DateRange, Wolfram Language function, https://reference.wolfram.com/language/ref/DateRange.html (updated 2023).
CMS
Wolfram Language. 2012. "DateRange." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023. https://reference.wolfram.com/language/ref/DateRange.html.
APA
Wolfram Language. (2012). DateRange. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DateRange.html
BibTeX
@misc{reference.wolfram_2026_daterange, author="Wolfram Research", title="{DateRange}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/DateRange.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_daterange, organization={Wolfram Research}, title={DateRange}, year={2023}, url={https://reference.wolfram.com/language/ref/DateRange.html}, note=[Accessed: 12-June-2026]}