---
title: "DayCount"
language: "en"
type: "Symbol"
summary: "DayCount[date1, date2] gives the number of days from date 1 to date 2. DayCount[date1, date2, daytype] gives the number of days of the specified daytype from date 1 to date 2."
keywords: 
- dates
- finance
- holidays
- holiday calendar
- business days
- islamic calendar
- jewish calendar
- gregorian
- julian
canonical_url: "https://reference.wolfram.com/language/ref/DayCount.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Date & Time"
    link: "https://reference.wolfram.com/language/guide/DateAndTime.en.md"
  - 
    title: "Financial Computation"
    link: "https://reference.wolfram.com/language/guide/Finance.en.md"
related_functions: 
  - 
    title: "DayPlus"
    link: "https://reference.wolfram.com/language/ref/DayPlus.en.md"
  - 
    title: "DayMatchQ"
    link: "https://reference.wolfram.com/language/ref/DayMatchQ.en.md"
  - 
    title: "DayRange"
    link: "https://reference.wolfram.com/language/ref/DayRange.en.md"
---
# DayCount

DayCount[date1, date2] gives the number of days from date1 to date2.

DayCount[date1, date2, daytype] gives the number of days of the specified daytype from date1 to date2.

## 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 (12)

### Basic Examples (4)

Print the number of days in a date range:

```wl
In[1]:= With[{first = Today}, DayCount[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}]]]

Out[1]= 27
```

---

Print the number of days that fall on a given day of the week:

```wl
In[1]:= With[{first = Yesterday}, DayCount[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], Sunday]]

Out[1]= 4
```

---

Print the number of business days in a date range:

```wl
In[1]:= With[{first = Tomorrow}, DayCount[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], "BusinessDay"]]

Out[1]= 18
```

---

Print all holidays in the current year, subject to the default holiday schedule:

```wl
In[1]:= With[{first = Now}, DayCount[first, DatePlus[first, {{1, "Year"}, {-1, "Day"}}], "Holiday"]]

Out[1]= 10
```

### Scope (2)

Compute the average number of weekend days this century:

```wl
In[1]:= Mean[Table[DayCount[{i}, {i + 1}, "Weekend"], {i, 2001, 2100}]]//N

Out[1]= 104.35
```

---

Compute the average number of non-weekend Swedish holidays this century:

```wl
In[1]:= Mean[Table[DayCount[{i}, {i + 1}, "Holiday", HolidayCalendar -> "Sweden"], {i, 2001, 2100}]]//N

Out[1]= 10.68
```

### Options (3)

#### CalendarType (1)

Count all US holidays that will occur in the current Islamic calendar year:

```wl
In[1]:= With[{first = CalendarConvert[Today, "Islamic"]}, DayCount[first, DatePlus[first, {{1, "Year"}, {-1, "Day"}}], "Holiday"]]

Out[1]= 10
```

#### HolidayCalendar (2)

Count holidays in India:

```wl
In[1]:= With[{first = Take[DateList[], 1]}, DayCount[first, DatePlus[first, {{1, "Year"}, {-1, "Day"}}], "Holiday", HolidayCalendar -> "India"]]

Out[1]= 12
```

---

Different markets within a country may have different holiday schedules:

```wl
In[1]:= CalendarData["UnitedStates"]

Out[1]= {"Default", "GovernmentBond", "NASDAQ", "NERC", "NYSE"}

In[2]:= With[{first = DateObject[{2022, 4}]}, DayCount[first, DatePlus[first, {{1, "Month"}}], "Holiday", HolidayCalendar -> {"UnitedStates", "NYSE"}]]

Out[2]= 1

In[3]:= With[{first = DateObject[{2022, 4}]}, DayCount[first, DatePlus[first, {{1, "Month"}}], "Holiday"]]

Out[3]= 0
```

### Applications (1)

Compute the number of days until the next US presidential election (first Tuesday after the first Monday in November of leap years):

```wl
In[1]:=
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[]]

Out[1]= 1005
```

### Properties & Relations (2)

``DayCount`` is equivalent to the length of the list output by ``DayRange`` for the same set of inputs:

```wl
In[1]:= With[{first = Today}, Length[DayRange[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}], "IncludeEndPoints" -> {False, True}]] == DayCount[first, DatePlus[first, {{1, "Month"}, {-1, "Day"}}]]]

Out[1]= True
```

---

Holidays, weekends, and business days always add up to the total number of days in the range:

```wl
In[1]:= DayCount[{2022}, {2023}, "Holiday"] + DayCount[{2022}, {2023}, "Weekend"] + DayCount[{2022}, {2023}, "BusinessDay"] - DayCount[{2022}, {2023}]

Out[1]= 0
```

## See Also

* [`DayPlus`](https://reference.wolfram.com/language/ref/DayPlus.en.md)
* [`DayMatchQ`](https://reference.wolfram.com/language/ref/DayMatchQ.en.md)
* [`DayRange`](https://reference.wolfram.com/language/ref/DayRange.en.md)

## Related Guides

* [Date & Time](https://reference.wolfram.com/language/guide/DateAndTime.en.md)
* [Financial Computation](https://reference.wolfram.com/language/guide/Finance.en.md)

## History

* [Introduced in 2012 (9.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn90.en.md) \| [Updated in 2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md) ▪ [2025 (14.3)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn143.en.md)