How Many Days Between Two Dates: Counting by Hand, in Excel and in Code
The question sounds simpler than it is: two dates, and the question of how many days sit between them. The temptation to add up the days in the months comes up almost every time, and almost every time it produces the wrong answer, one, two or three days out. It is worth understanding once, because counting days between dates shows up in holiday calculations, contract deadlines, quarantine periods, a child age and in any other total where months and years get mixed together and an error can hide easily.
The quick answer and the tool that does it
Open the date difference calculator, enter two dates, and it gives you the gap in days, weeks, months and years, plus the same interval expressed in hours, minutes and seconds. If the question is really "how much is left" rather than "how much has passed", the reverse direction works too: the date add calculator shows the resulting date and its weekday, and it can count business days instead of calendar days.
What follows is an explanation of how these numbers actually come out, because understanding the mechanics saves you from mistakes in the cases where no calculator is at hand.
Why you cannot simply add up the days in the months
Because months are not all the same length. A year has ten months of 31 days, four of 30 days, one of 28 and one that is either 28 or 29. Between two dates carrying the same day number, what fits is not one fixed sum but the sum of the lengths of the months in between, and that sum changes depending on which year you happen to be looking at.
15 January 2026 → 15 March 2026
rest of January 16 days + February 28 + March 15 = 59 days
15 January 2024 → 15 March 2024
rest of January 16 days + February 29 + March 15 = 60 days
One day apart, although both sit in the middle of winter.The second trap is that "between two dates" and "length of the period" are different numbers. Counting from 3 November 2026 to 1 January 2027 gives an interval of 59 days: the 3rd is left out and the 1st is counted. If you need the length of a period where both ends are included, you get 60.
Leap years and the century rule
A year is a leap year when it divides by 4, unless it divides by 100 and does not divide by 400. That leaves four exceptions in every four hundred years: 1700, 1800, 1900 and 2100 were not leap years, while 1600 and 2000 were. This is what keeps the average year at 365.2425 days and makes the calendar repeat itself exactly every 400 years, of which 97 are leap.
- 2024 divides by 4 and not by 100, so it is a leap year with 366 days;
- 1900 divides by 100 but not by 400, so it is an ordinary year with 365 days;
- 2000 divides by 400, so it is a leap year with 366 days;
- 2100 falls out again, dividing by 100 and not by 400, so 365 days;
- 2026 does not divide by 4 at all, so it is an ordinary year with 365 days.
Three test points are enough to check the rule: 2024 is a leap year, 1900 is not, 2000 is. 1900 and 2000 are exactly where the simplified "every fourth year" rule that almost everybody remembers breaks down.
Why centuries drop out of the rule
Astronomers had gathered enough observations to see that the tropical year is about 11 minutes and 14 seconds shorter than 365.25 days. Dividing by 4 and nothing else let those losses accumulate until the calendar drifted by roughly a full day over four centuries, which is when the spring equinox starts sliding around the calendar. That is why ten days were dropped in 1582, and why the Gregorian calendar gives 97 leap years out of every 400. The century rule is not an arithmetic whim, it is an attempt to keep up with the mechanics of the sky.
Counting by hand in three steps
- Drop the days that have already passed in the starting month: subtract the start day from the length of that month.
- Add the full length of every month that falls entirely inside the period, and do not forget the 29th of February if a leap year is in there.
- Add the day number of the final month if it counts.
November 2026: 30 - 3 = 27 days left after the 3rd
December 2026: 31 days in full
January 2027: 1 day (the date itself)
───────────────────────────────
27 + 31 + 1 = 59 days
In weeks: 59 = 8 full weeks and 3 days
Counting both end days: 60A useful cross-check: 2026 has 365 days and 3 November is day 307 of the year, so 365 - 307 = 58 days remain to the end of the year, plus one more to 1 January, giving 59. That route does not depend on reading a calendar carefully, and arithmetic catches a mistake immediately.
Including the first day or not
The difference between 59 and 60 days in the same question looks like a trifle, and that is precisely where people slip. The phrase "how many days between two dates" conventionally means the start day is not counted and the end day is. The phrase "how many days does the period from X to Y last" means both ends are inside it.
It matters wherever there is a deadline. If a contract says "within 30 days from 3 November", the 3rd is not one of those 30 days and the last day of the term is 2 December. If the period is counted inclusively, the 30 days end on 1 December. In holiday calculations, in the window for filing a claim or in a quarantine period, the gap between those two readings is worth a full day.
The practical rule that follows: ask yourself how many complete 24 hour periods sit between two moments. Between midnight on 3 November and midnight on 1 January there are exactly 59 of them. If you are counting calendar days rather than a gap between two moments, add one.
Business days and why they are harder
Subtracting weekends is straightforward, because Saturday and Sunday come from the calendar. Subtracting public holidays as well gets much harder, because the official days off in Russia do not line up with the calendar: the government moves holidays onto nearby weekdays and declares some Saturdays working.
Total days in the period: 59
Saturdays: 8
Sundays: 8
Working days (Mon-Fri): 43
That is before public holidays. 1 January 2027
falls on a Friday, and if the day off is moved
to Monday the working days become 42.The exact figure is only known from the official production calendar, published every year by the Ministry of Labour. It also shows which Saturdays are working days and which are shortened to six hours. Working these things out by hand only makes sense for a rough estimate.
Excel: DAYS, DATEDIF and NETWORKDAYS
Excel has three different instruments for three different questions. The simplest is for when both dates sit in cells as real dates: subtract one cell from the other and you get a number of days, after which you only have to set the cell format to Number. DAYS does the same thing explicitly and accepts dates in either order. DATEDIF answers the subtler questions, because it counts whole months and whole years. NETWORKDAYS counts working days.
=B2-A2 → 59 (days between the dates)
=DAYS(B2,A2) → 59
=DATEDIF(A2,B2,"d") → 59 (days)
=DATEDIF(A2,B2,"m") → 1 (whole months)
=DATEDIF(A2,B2,"y") → 0 (whole years)
=NETWORKDAYS(A2,B2) → 43 (working days, Mon-Fri)
=NETWORKDAYS.INTL(A2,B2,"2") → 43 (week starts on Monday)
=NETWORKDAYS(A2,B2,$H$1:$H$5) → 43 (minus holidays in the range)
=YEARFRAC(A2,B2,1) → 0.162 (fraction of a year)Two traps to watch for. First, if the dates went in as text rather than as dates, subtraction throws an error and sometimes quietly returns something meaningless; in a Russian locale the safe route is =DATE(2026,11,3). Second, NETWORKDAYS without a third argument assumes Saturday and Sunday are the weekend, and since the Russian production calendar adds extra days off, your total will always come out a few days too high.
Code in Python and JavaScript
Python gives you the answer directly: the difference of two date objects is a timedelta, and its days attribute is the count, with no arithmetic required. To break the interval into years, months and days, use relativedelta from the python-dateutil package, which also adds months without breaking on the 31st.
from datetime import date
from dateutil.relativedelta import relativedelta
start = date(2026, 11, 3)
end = date(2027, 1, 1)
delta = end - start
delta.days # 59
delta.days // 7, delta.days % 7 # (8, 3)
r = relativedelta(end, start)
r.years, r.months, r.days # (0, 1, 29) → 1 month and 29 daysJavaScript has no date type of its own, so you count in milliseconds and divide by the number of milliseconds in a day. Always round the result, and here is why: in countries that observe daylight saving, the gap between two midnights is sometimes 23 hours and sometimes 25. The division then produces a fraction, and without rounding the answer slips by a whole day.
const MS_PER_DAY = 86_400_000;
// The numeric constructor gives local time with no UTC surprises
const start = new Date(2026, 10, 3); // 3 November 2026
const end = new Date(2027, 0, 1); // 1 January 2027
const days = Math.round((end - start) / MS_PER_DAY); // 59
// Split into weeks and days
const weeks = Math.floor(days / 7), rest = days % 7; // 8 and 3If the count has to run in calendar days regardless of time zones, it is safer to compare dates normalised to midnight UTC rather than local Date objects. In every other case, remember the ISO 8601 format, where a date is written unambiguously and cannot be misread when it travels between systems.
Questions people keep asking
How many days are left until New Year?
You count from the current date to 1 January of the next year. From 3 November 2026 to 1 January 2027 there are 59 days left, which is eight full weeks and three days. Checking against the calendar: 27 days remain in November, December brings 31 days and then the 1st itself, giving 59. Count both end days and you get 60.
How do I count days between dates in Excel?
The shortest version is to put both dates in cells A2 and B2, type =B2-A2 and then change the result cell format from Date to Number, otherwise Excel keeps showing a date. DAYS(B2,A2) does the same thing and also works when the dates are the wrong way round. For months and years you want DATEDIF, and for working days without holidays, NETWORKDAYS.
How many days are in 2026?
365, because 2026 does not divide by 4 and is not a leap year. 2027 has 365 days as well, while 2028 will be a leap year with 366. For comparison: 2024 had 366 days, 2025 had 365, 2026 has 365, 2027 has 365, and 2028 goes back to 366.
Does the first day count?
By default it does not. The phrase "how many days between two dates" describes the gap between two moments, so the start day is left out and the end day is counted. From 3 November 2026 to 1 January 2027 that gives 59 days. If you need the length of a period with both ends included the answer is 60, and it is worth saying so out loud rather than discovering the difference later in an argument with an accountant.
How do I count the days since a birth date?
The same way: subtract the dates to get days. If you need an age in whole years, months and days, that is a separate question with a wrinkle in it. The age calculator handles it, including the fact that 29 February does not exist in an ordinary year and the birthday falls on 1 March instead. For the weekday a date lands on, the weekday calculator gives you the answer.
Date Difference Calculator
Calculate the exact difference between two dates in multiple units
Date Plus Days Calculator
Add or subtract calendar or business days from a date and see the weekday you land on
Day of Week Calculator
Find what day of the week any date falls on, plus the day of year, ISO 8601 week number and whether the year is a leap year
Age Calculator
Exact age in years, months and days — plus a countdown to the next birthday.