How Many Days Between Two Dates – Quick Answer + Examples
By Deepak·
To find how many days between two dates, subtract the earlier date from the later one. That gives you the total number of days elapsed. You can do this by hand, with a calculator tool, or in code — and each method takes less than a minute.
How Many Days Between Two Dates: The Simple Formula
The core idea is straightforward: count every calendar day from the start date up to (but not including) the end date. That gap is called the day difference or date interval.
For quick answers without any arithmetic, use our date difference calculator — plug in both dates and it returns the result instantly.
What is the fastest way to calculate days between two dates?
Subtract the start date from the end date in a tool or spreadsheet. For example, the number of days between 1 January 2024 and 1 March 2024 is 60 days (2024 is a leap year, so February has 29 days). A dedicated date calculator handles leap years and month lengths automatically, so you never have to count by hand.
Worked Example: Counting Days Step by Step
Suppose you need the number of days between 15 March 2024 and 10 August 2024.
- March 15 → March 31 = 16 days
- April = 30 days
- May = 31 days
- June = 30 days
- July = 31 days
- August 1 → August 10 = 10 days
- Total: 148 days
Doing this manually is fine for a one-off, but it gets tedious fast — especially when date ranges cross February in a leap year. Code and calculators handle that automatically.
Calculate Days Between Two Dates in Code
Here are minimal, copy-pasteable examples in three common languages.
Python
# Python 3 — uses the built-in datetime module
from datetime import date
start = date(2024, 3, 15)
end = date(2024, 8, 10)
delta = end - start
print(delta.days) # 148
Python's date objects subtract directly. The result is a timedelta object; its .days attribute gives the integer count. See the official Python datetime docs for full details.
JavaScript
// JavaScript — works in any browser console or Node.js
const start = new Date('2024-03-15');
const end = new Date('2024-08-10');
const msPerDay = 1000 * 60 * 60 * 24;
const days = Math.round((end - start) / msPerDay);
console.log(days); // 148
JavaScript dates subtract as milliseconds, so dividing by milliseconds-per-day converts to days. Math.round() guards against daylight saving time shifts that can make the raw result 147.958 instead of 148 — a classic gotcha covered below. The MDN Date reference explains the full API.
Microsoft Excel / Google Sheets
=DAYS(B1, A1)
Put the end date in B1 and the start date in A1. The DAYS function returns the positive day count directly. You can also just type =B1-A1 and format the cell as a number.
Common Gotchas That Throw Off the Count
Getting the math wrong is easy if you overlook these traps:
- Leap years — February has 29 days in a leap year (any year divisible by 4, except century years not divisible by 400). Always verify when your range crosses February.
- Daylight Saving Time (DST) — Clocks skip or repeat an hour on DST transition days. In JavaScript, if you subtract two
Dateobjects that straddle a DST change, the raw millisecond difference may equal 23 or 25 hours rather than exactly 24. UsingMath.round()(as above) fixes this. - Inclusive vs exclusive end date — "Days between March 15 and March 17" could mean 2 days (exclusive) or 3 days (inclusive, counting both endpoints). Be explicit about which convention you need — payroll systems often use inclusive, while programming languages default to exclusive.
- Time zones — If your start and end are timestamps in different time zones, convert both to the same zone before calculating. Our time zone converter can help you align times before you do the math.
- Date string formats —
03/04/2024means April 3 in the US but March 4 in the UK. Always use the unambiguous ISO 8601 format (YYYY-MM-DD) in code and tools to avoid silent errors. The ISO 8601 standard is maintained by the International Organization for Standardization.
Days Between Dates vs. Related Calculations
The day count is often a building block for something bigger. Here is how it fits alongside other common needs:
| You need to know… | Best approach |
|---|---|
| Exact days between two calendar dates | Date difference calculator or code subtraction |
| Your age in years, months, and days | Age calculator (handles partial months too) |
| A date X days from now | Date calculator — add or subtract days, months, years |
| Scheduling across time zones | Time zone converter |
Frequently Asked Questions About Days Between Two Dates
How do I count the number of days between two dates in Excel?
Use the formula =DAYS(end_date, start_date) or simply subtract one date cell from the other (=B1-A1) and format the result as a number. Excel stores dates as serial numbers, so subtraction gives you the exact day count automatically, including leap years.
Does the calculation include the start date and end date?
By default, most tools and programming languages count exclusive of the end date — so the gap from March 1 to March 3 is 2 days, not 3. If you need to include both endpoints (common in contract or event counting), add 1 to the result.
How many days between two dates if one of them is today?
Use today's date as your start (or end) point. In Python, date.today() returns the current date; in JavaScript, new Date() does the same. Our date difference calculator also has a "today" shortcut so you don't have to type today's date manually.
How is counting days between dates different from counting months or years?
Days are always the same length (86,400 seconds, DST aside), so day counts are exact and unambiguous. Months and years vary in length, which is why tools like our age calculator express age in years and months and remaining days — three separate numbers rather than one decimal.