DayRange
Details and Options
- DayRange returns a list of DateObject elements.
- A date can be specified in the following forms:
-
DateObject[…] date object {y,m,d} year, month, day {y,m} the first day of the specified month {y} January 1 of the year y "string" date as a string ("Jan. 1, 2000") {y,m,d,h,m,s} precise time time absolute time specification - Possible day types are:
-
All any calendar date (default) "Weekday" date considered a weekday "Weekend" date considered a weekend "Holiday" holiday according to HolidayCalendar "NonHoliday" date that is not a holiday "BusinessDay" non-holiday weekday "NonBusinessDay" holiday or weekend "WeekdayHoliday" holiday on a weekday "WeekendHoliday" holiday on a weekend "WeekendNonHoliday" non-holiday weekend Monday, Tuesday, … a specific day of the week "EndOfMonth" final day of a given month "BeginningOfMonth" first day of a given month - In the Jewish calendar, the weekdays are Sunday through Thursday.
- DayRange takes the following options:
-
CalendarType Automatic calendar in which the dates have been specified HolidayCalendar {"UnitedStates","Default"} holiday schedule and subspecification for the business day and holiday computations "IncludeEndPoints" {True,True} whether date1 and date2 are to be included in the range
Examples
open all close allBasic Examples (4)
Print all the dates in a date range:
DayRange[Yesterday, Tomorrow]Print all dates that fall on a given day of the week:
With[{first = Take[DateList[], 2]}, DayRange[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], Sunday]]Print all business days in the date range:
DayRange[DateObject[{2022, 1, 1}], DateObject[{2022, 1, 31}], "BusinessDay"]Print all holidays in the current year, subject to the default holiday schedule:
With[{firstday = DayRound[CurrentDate["Year"]]}, DayRange[firstday, DatePlus[firstday, {{1, "Year"}, {-1, "Day"}}], "Holiday"]]Scope (1)
Options (4)
CalendarType (1)
HolidayCalendar (2)
DayRange[{2012}, {2012, 12, 31}, "Holiday", HolidayCalendar -> "India"]Different markets within a country may have different holiday schedules:
CalendarData["UnitedStates"]With[{first = {2012, 4}}, DayRange[first, DatePlus[first, {{1, "Month"}}], "Holiday", HolidayCalendar -> {"UnitedStates", "NYSE"}]]With[{first = {2012, 4}}, DayRange[first, DatePlus[first, {{1, "Month"}}], "Holiday"]]Applications (1)
Compute the number of days until the next US presidential election (first Tuesday after the first Monday in November of leap years):
nextelection[date_] := Module[{year = 4Ceiling[date[[1]] / 4], nearest},
nearest = DatePlus[DayRange[{year, 11, 1}, {year, 11, 30}, Monday][[1]], 1];
If[QuantityMagnitude[DateDifference[date, nearest]] > 0, DayCount[date, nearest], DayCount[date, DatePlus[DayRange[{year + 4, 11, 1}, {year + 4, 11, 30}, Monday][[1]], 1]]]//Floor];
nextelection[DateList[]]Properties & Relations (3)
DayCount is equivalent to the length of the list output by DayRange for the same set of inputs:
With[{first = Take[DateList[], 2]}, Length[DayRange[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], "BusinessDay", "IncludeEndPoints" -> {False, True}]] == DayCount[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], "BusinessDay"]]DayRange with a day type specification other than All is equivalent to a Select statement:
DayRange[{2022}, {2023}, "Weekend"] == Select[DayRange[{2022}, {2023}], DayMatchQ[#, "Weekend"]&]Weekends, non-weekend holidays, and business days form three non-overlapping sets:
With[{sets = {DayRange[{2022}, {2023}, "Holiday"], DayRange[{2022}, {2023}, "Weekend"], DayRange[{2022}, {2023}, "BusinessDay"]}}, Union@@sets == ((Join@@sets)//Sort)]Possible Issues (1)
A date may only be a holiday if it is not a weekend:
With[{first = {2012, 7}}, DayRange[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], "Weekend"]]With[{first = {2012, 7}}, DayRange[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], "Holiday", HolidayCalendar -> {"Gregorian" -> {{True&, # == 7&, 1 ≤ # ≤ 31&}}}]]Related Guides
Text
Wolfram Research (2012), DayRange, Wolfram Language function, https://reference.wolfram.com/language/ref/DayRange.html (updated 2025).
CMS
Wolfram Language. 2012. "DayRange." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/DayRange.html.
APA
Wolfram Language. (2012). DayRange. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DayRange.html
BibTeX
@misc{reference.wolfram_2026_dayrange, author="Wolfram Research", title="{DayRange}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/DayRange.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_dayrange, organization={Wolfram Research}, title={DayRange}, year={2025}, url={https://reference.wolfram.com/language/ref/DayRange.html}, note=[Accessed: 13-June-2026]}