DayCount
Details and Options
- Dates 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} the first day of the first month of the year y "string" date as a string ("Jan. 1, 2000") - Possible day types are:
-
All any calendar date (default) "Weekday" date considered a weekday "Weekend" date considered a weekend "Holiday" holiday according the 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 - DayCount excludes the beginning date of the date range.
- DayCount 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 - In the Jewish calendar, the weekdays are Sunday through Thursday.
Examples
open all close allBasic Examples (4)
Print the number of days in a date range:
With[{first = Today}, DayCount[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}]]]Print the number of days that fall on a given day of the week:
With[{first = Yesterday}, DayCount[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], Sunday]]Print the number of business days in a date range:
With[{first = Tomorrow}, DayCount[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], "BusinessDay"]]Print all holidays in the current year, subject to the default holiday schedule:
With[{first = Now}, DayCount[first, DatePlus[first, {{1, "Year"}, {-1, "Day"}}], "Holiday"]]Scope (2)
Compute the average number of weekend days this century:
Mean[Table[DayCount[{i}, {i + 1}, "Weekend"], {i, 2001, 2100}]]//NCompute the average number of non-weekend Swedish holidays this century:
Mean[Table[DayCount[{i}, {i + 1}, "Holiday", HolidayCalendar -> "Sweden"], {i, 2001, 2100}]]//NOptions (3)
CalendarType (1)
HolidayCalendar (2)
With[{first = Take[DateList[], 1]}, DayCount[first, DatePlus[first, {{1, "Year"}, {-1, "Day"}}], "Holiday", HolidayCalendar -> "India"]]Different markets within a country may have different holiday schedules:
CalendarData["UnitedStates"]With[{first = DateObject[{2022, 4}]}, DayCount[first, DatePlus[first, {{1, "Month"}}], "Holiday", HolidayCalendar -> {"UnitedStates", "NYSE"}]]With[{first = DateObject[{2022, 4}]}, DayCount[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 (2)
DayCount is equivalent to the length of the list output by DayRange for the same set of inputs:
With[{first = Today}, Length[DayRange[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], "IncludeEndPoints" -> {False, True}]] == DayCount[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}]]]Holidays, weekends, and business days always add up to the total number of days in the range:
DayCount[{2022}, {2023}, "Holiday"] + DayCount[{2022}, {2023}, "Weekend"] + DayCount[{2022}, {2023}, "BusinessDay"] - DayCount[{2022}, {2023}]Related Guides
Text
Wolfram Research (2012), DayCount, Wolfram Language function, https://reference.wolfram.com/language/ref/DayCount.html (updated 2025).
CMS
Wolfram Language. 2012. "DayCount." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/DayCount.html.
APA
Wolfram Language. (2012). DayCount. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DayCount.html
BibTeX
@misc{reference.wolfram_2026_daycount, author="Wolfram Research", title="{DayCount}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/DayCount.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_daycount, organization={Wolfram Research}, title={DayCount}, year={2025}, url={https://reference.wolfram.com/language/ref/DayCount.html}, note=[Accessed: 13-June-2026]}