Como calcular dias entre duas datas: formula e calculadora
Aprenda a calcular a diferenca em dias, semanas e meses entre datas.
Why you need to calculate days between dates
Calculating the difference between two dates is needed in many contexts:
- Work: Accumulated vacation days, seniority, notice periods. Many countries calculate severance by exact days worked.
- Legal: Filing deadlines (30 business days to appeal), statute of limitations (1,825 days = 5 years), contract expiration.
- Financial: Bank interest calculated by exact days. A 90-day vs 92-day loan changes total interest.
- Health: Pregnancy weeks (280 days from last period), gestational age, vaccine intervals.
- Personal: Days until an event (wedding, trip, exam), exact age in days.
- Projects: Days to completion, agile sprints (14 days), deadlines.
Calculate instantly with the NexTools date difference calculator.
How to calculate the difference between two dates
Calendar days vs business days:
- Calendar days: All days including weekends and holidays. Jan 1-31 = 30 days.
- Business days: Monday-Friday only (no holidays). Jan 1-31, 2026 ≈ 22 business days.
Include or exclude the final day: "From the 1st to the 5th" can be 4 days (excludes 5th) or 5 days (includes both). Legal contexts usually exclude the start day and include the end day.
Leap years: February has 29 days in leap years (2024, 2028, 2032). "One year" can be 365 or 366 days.
Example: March 15 to June 20, 2026: 16 + 30 + 31 + 20 = 97 days.
The NexTools calculator does this instantly, including weeks, months, and years.
Difference in days, weeks, months, and years
Example: Jan 1, 2025 to Mar 17, 2026:
- Days: 440
- Weeks: 62 weeks and 6 days
- Months: 14 months and 16 days
- Years: 1 year, 2 months, 16 days
Month length varies: Months have 28-31 days. "One month" after January 31 is... February 28? March 2? Depends on context.
For exact age calculation, use the NexTools age calculator.
Calculating business days between two dates
Basic formula: Business days ≈ Calendar days × 5/7 (no holidays). For 30 calendar days: ~21 business days.
Complications:
- Holidays vary by country, state, and city. US has 11 federal holidays; UK has 8 bank holidays; Mexico has 7 official.
- Some sectors work Saturdays (retail, healthcare).
Rule of thumb: A month has ~22 business days. A year has ~250-260 business days.
For financial calculations, use the NexTools percentage calculator for interest.
Use cases: legal, financial, and work deadlines
Legal: Statute of limitations: US varies by state (1-10 years), UK 6 years for most debts. Appeal deadlines: typically 5-30 business days.
Financial: Bank interest: exact days / 360 or 365 depending on convention. CDs: 30, 60, 90 exact days.
Work: Vacation calculated by business days worked. Notice periods: typically 2-4 weeks. Severance: proportional to exact days.
Calculate days between dates in Excel and Google Sheets
Simple days: =B1-A1
Business days: =NETWORKDAYS(A1, B1). With holidays: =NETWORKDAYS(A1, B1, C1:C10).
Years, months, days: =DATEDIF(A1, B1, "Y") & " years, " & DATEDIF(A1, B1, "YM") & " months, " & DATEDIF(A1, B1, "MD") & " days"
Add days: =A1+90 adds 90 calendar days. =WORKDAY(A1, 90) adds 90 business days.
For quick use, the NexTools date calculator gives the same result instantly.
Calculate days between dates in code
JavaScript:
const start = new Date('2025-01-01');
const end = new Date('2026-03-17');
const diff = Math.floor((end - start) / (1000 * 60 * 60 * 24));
console.log(diff); // 440 days
Python:
from datetime import date
d1 = date(2025, 1, 1)
d2 = date(2026, 3, 17)
print((d2 - d1).days) # 440
Timezone warning: JavaScript's new Date() uses local timezone. Cross-timezone calculations can have ±1 day errors. Use Date.UTC() for precision.
For Unix timestamps, see our timestamp converter.
Calendar curiosities and fun facts about days
Why months have different lengths: The Roman calendar originally had 10 months (304 days). January and February were added later. Julius Caesar (July) and Augustus (August) adjusted months to have 31 days, taking from February.
Leap years aren't every 4 years: Full rule: leap if divisible by 4, EXCEPT divisible by 100, EXCEPT divisible by 400. So 2100 will NOT be a leap year, but 2000 was.
The Year 2038 problem: 32-bit Unix timestamps overflow on January 19, 2038. Like Y2K but for 32-bit timestamp systems.
Days in a lifetime: Living 80 years ≈ 29,200 days. Sleeping 8 hours daily = ~9,733 days asleep. That leaves ~19,467 waking days.
Experimente esta ferramenta:
Abrir ferramenta→Perguntas frequentes
How do I calculate days between two dates including both days
Add 1 to the result. If Jan 1-5 normally gives 4 days (excludes start), adding 1 gives 5 (includes both). NexTools lets you choose whether to include the final day.
What is the difference between calendar days and business days
Calendar days include all days (Mon-Sun). Business days exclude Saturdays, Sundays, and holidays. A month has ~30 calendar days but ~22 business days.
How do leap years affect day calculations
Leap years have 366 days (Feb 29). If your range includes Feb 29, you have 1 extra day. Recent leap years: 2020, 2024, 2028. Not leap despite divisible by 4: 2100, 2200.
Can I calculate business days with the NexTools calculator
NexTools calculates calendar days. For exact business days you need your country's holidays. Approximation: business days ≈ calendar days × 5/7.
How do I calculate weeks until a date
Calculate days between today and the target, divide by 7. Example: 97 days / 7 = 13 weeks and 6 days. NexTools shows results in weeks automatically.
Why do Excel and JavaScript give different results for the same dates
Timezone differences. Excel calculates in local time unambiguously. JavaScript's new Date() uses browser timezone, which can cause ±1 day differences near midnight. Use Date.UTC() to avoid this.