Guide · Text, dates and developer tools

How to Calculate the Days Between Two Dates (By Hand, Excel and SQL)

In short

To find the days between two dates, subtract the earlier date from the later one. From October 20, 2026 to December 25, 2026 is 66 days, or 67 if you count both ends. As years, months and days it is 2 months, 5 days: add whole months to the start, then count the days left over.

The basic method: subtract the dates

The number of days between two dates is the later date minus the earlier one, with each date turned into a count of days. A computer does this by giving every date a day number, as 20 October 2026 is day 20,746 counted from 1 January 1970, and subtracting. By hand, add up three pieces: the days left in the start month, the whole months in between, and the days into the end month.

  1. Days left in the start month. October has 31 days, so after the 20th there are 11 left.
  2. Whole months in between. November has 30 days.
  3. Days into the end month. December 25 is 25 days in.
  4. Add them: 11 + 30 + 25 = 66 days, which matches 66.
Date calculatorEnter two dates in the date calculator and it shows the answer in days, weeks, months and years, with every step written out.

Count the end date or not?

The subtraction method gives the difference, which leaves out one end of the range. Today to tomorrow is one day, even though two dates are involved. That matches how most people count a gap: 66 days from October 20, 2026 to December 25, 2026. If both the first and the last day count, as for days of leave or a conference, add one: 67.

Which count fits which situation
SituationCountExample from 20 to 25 October
Days until an event, age in daysExclusive (subtract)5 days
Days of leave, conference days, a stay where each calendar day countsInclusive (add one)6 days
Nights in a hotelExclusive5 nights
A legal or contractual periodAs the document defines itRead the clause

Contracts and laws often say whether the first day counts, for example “within 30 days of the date of the notice” usually starts the count on the day after. This guide cannot tell you which rule applies to your deadline. Check the wording, and if the stakes are high ask the body that sets the deadline.

Years, months and days: where tools disagree

Days between dates is unambiguous. Years, months and days is not, because months have different lengths. The date calculator on this site adds whole months to the earlier date for as long as that does not pass the later one, then counts the days left. For October 20, 2026 to December 25, 2026: two whole months takes you to December 20, 2026, a third would pass the end, and 5 days remain, so the answer is 2 months, 5 days.

The awkward case is a month end. There is no 31 February, so adding one month to January 31, 2026 gives February 28, 2026, the last day of February. The calculator moves a date back to the last day of a shorter month, which is also what most databases and calendar libraries do. The gap from January 31, 2026 to March 1, 2026 then comes out as 1 month, 1 day. Another tool could count it as one month and a day, or as 29 days, and not be wrong, only different.

A spreadsheet warning Excel and Google Sheets have a DATEDIF function with units for complete years (“Y”), complete months (“M”) and total days (“D”). Microsoft says not to use its “MD” unit, which gives the days ignoring months and years, because it has known limitations and can return a negative number, zero or an inaccurate result. For whole years and months it is reliable; for the leftover days, subtract the first of the end date’s month instead.

Leap years

A year is a leap year when it divides by 4, except for century years, which must divide by 400. So 2024 and 2000 were leap years, and 1900 and 2100 are not. A leap year has 366 days, with 29 days in February, and that day is why a day count between two dates is not simply years times 365. From 1 January 2000 to October 20, 2026 is 9,789 days, which is 26 years, 9 months, 19 days. Twenty-six whole years of 365 days would be 9,490; the 292 days from 1 January to October 20, 2026 are added, and 7 more come from the leap days of 2000, 2004, 2008, 2012, 2016, 2020 and 2024.

Adding a year to 29 February also needs a rule. The calculator moves it to February 28, 2025, the last day of February in a year that has no 29th.

Weekdays only

For business use you may want only Monday to Friday. Count the whole weeks (each has five weekdays) and then the leftover days one by one. Between October 20, 2026 and December 25, 2026, counting both ends, there are 49 weekdays. This does not remove public holidays, which differ by country and year. The working days calculator lets you pick your own weekend and add holidays, and the date calculator’s “weekdays” figure is a Monday-to-Friday count with nothing taken out.

Working days calculatorTo take out public holidays, or to use a Friday and Saturday weekend, use the working days calculator.

The same calculation in a spreadsheet, a database and code

Many people searching for this want a formula. These all give 66 for 2026-10-20 to 2026-12-25; the date calculator writes them out for your own dates.

Days between 2026-10-20 and 2026-12-25
WhereFormula
Excel or Google Sheets (dates in A1 and B1)=B1-A1
Excel or Google Sheets, same result=DATEDIF(A1,B1,"d")
Excel or Google Sheets, weekdays only=NETWORKDAYS(A1,B1)
PostgreSQLSELECT DATE '2026-12-25' - DATE '2026-10-20';
MySQLSELECT DATEDIFF('2026-12-25', '2026-10-20');
SQL ServerSELECT DATEDIFF(day, '2026-10-20', '2026-12-25');
SQLiteSELECT julianday('2026-12-25') - julianday('2026-10-20');
Python(date(2026, 12, 25) - date(2026, 10, 20)).days
JavaScriptMath.round((Date.UTC(2026, 11, 25) - Date.UTC(2026, 9, 20)) / 86400000)

To add 30 days: in a spreadsheet use =A1+30, in PostgreSQL SELECT DATE '2026-10-20' + 30, and in Python add timedelta(days=30). The result for October 20, 2026 is November 19, 2026. In JavaScript, build dates with Date.UTC and divide the difference by 86,400,000, because local-time dates can be off by an hour across a daylight saving change and produce a fractional day.

Week numbers and weeks between dates

Weeks between dates is the day count divided by seven, with a remainder: 66 days is 9 weeks and 3 days. A week number is a different idea. The ISO 8601 standard starts weeks on Monday and calls the week that holds the year’s first Thursday week 1, so the first days of January can belong to week 52 or 53 of the year before. Friday, January 1, 2027 falls in ISO week 53 of 2026. The US convention of counting weeks from Sunday gives different numbers around the new year, so say which you mean when a deadline is given as a week.

A checklist before you trust the answer

  • Is the end date counted? Decide, and say it.
  • Are you counting calendar days, or business days with holidays removed?
  • If the answer will go into a contract, a visa or a court date, have the wording checked by whoever sets the deadline.
  • Does a time zone matter? A deadline at midnight in one place is a different day somewhere else. The calculator works with plain dates and clock times, with no time zone.
  • If a formula and a calculator disagree, test the formula on a pair of dates whose answer you can count by hand.

A final check: December 25, 2026 should equal December 25, 2026, because 66 days after 2026-10-20 is 2026-12-25. Counting forward and back should always land on the same date.

Common questions

How many days are there between two dates?
Subtract the earlier from the later. For 2026-10-20 to 2026-12-25 it is 66 days, or 67 if both the first and last day are counted.
How do I count the days between two dates in Excel?
Subtract the cells: with dates in A1 and B1, =B1-A1 gives the days. =DATEDIF(A1,B1,"d") gives the same, and NETWORKDAYS(A1,B1) counts weekdays.
Is the end date included when you subtract?
No. Subtracting gives the difference, so the end date is not counted. Add one day if you want both the first and last day counted.
How many days are in a leap year?
A leap year has 366 days, with 29 days in February. A year is a leap year if it divides by 4, except century years, which must divide by 400.
What date is 30 days from today?
Add 30 to the date, carrying over months as needed. 30 days after 20 October 2026 is 19 November 2026. The date calculator does this for any date and shows the weekday.
How do I get the number of weekdays between two dates?
Count Monday to Friday only. Between 2026-10-20 and 2026-12-25, both included, there are 49. Holidays are not removed, so use a working days calculator if they matter.

Sources

Reviewed on 20 Oct 2026 against the published sources below. Laws and prices change, so check the current position before you rely on a figure.

Try the calculator

Keep reading

This guide is general information, not legal, financial or religious advice. Figures are estimates worked out from the sources above and may differ from what applies to you. See the disclaimer. Found a mistake? Tell us.