Day Counter
Counts days between two dates (including or excluding weekends). Also computes weeks, months and full years.
How do we count days?
The day count relies on UTC timestamps, which keeps timezone jumps out of the picture. Tick "exclude weekends" and Saturdays and Sundays drop out of the sum, handy for business-day deadlines.
The totals in weeks, months and years, in turn, are derived from the day total.
Your data isn't sent anywhere.
Day counting: a deep guide to dates, deadlines and date arithmetic
Counting the number of days between two dates sounds trivial — subtract one from the other — but in practice the operation hides a surprising amount of complexity. Calendars have irregular month lengths, leap years, historical reforms that erased ten days from October 1582, daylight saving transitions that shorten or stretch a local day, and legal regimes that draw sharp distinctions between calendar days, business days and commercial days. A modern day counter has to navigate all of this and still produce an answer that a court, a payroll department or a logistics planner will accept. This page gathers the conceptual background you need to read the result correctly and to know when you should reach for a calculator at all.
Calendar days, business days and commercial days
A calendar day is any 24-hour block from midnight to midnight in the chosen civil time zone. Counting calendar days between two dates means including every single day of the interval, weekends and holidays alike. This is the simplest mode and the one most contracts use by default when they say only "days" without further qualification.
A business day, or working day, excludes Saturdays, Sundays and official holidays from the count. The exact definition depends on jurisdiction: Brazilian procedural law and Brazilian financial markets use Monday to Friday minus federal holidays; some banking conventions also drop municipal holidays in the city where the obligation is performed; certain shift schedules (6x1) treat Saturday as working. Always check which holiday list the counterpart will apply before you commit to a deadline.
A commercial day is a conventional 30-day month used in finance and accounting. The Brazilian "dia comercial" assumes 360 commercial days per year, 30 per month, and is used in older interest formulas, in some leasing contracts and in actuarial tables. It does not match calendar reality but simplifies arithmetic — which is exactly the point. When you see expressions like "15/360" or "exact/360" in a loan contract, the denominator is telling you which convention to apply.
Brazilian national holidays (Laws 662/1949, 6.802/1980, 9.093/1995, 13.819/2019)
Brazil's national holidays are defined by a small stack of federal statutes. Law 662 of 6 April 1949 declared 1 January (Confraternização Universal), 21 April (Tiradentes), 1 May (Dia do Trabalho), 7 September (Independência), 2 November (Finados), 15 November (Proclamação da República) and 25 December (Natal) as national holidays. Law 6.802 of 30 June 1980 added 12 October as the day of Nossa Senhora Aparecida, patron saint of Brazil. Law 9.093 of 12 September 1995 classifies civil and religious holidays and allows states and municipalities to enact their own days off (carnival, the local saint's day, the date of municipal foundation, and so on). Law 13.819 of 26 April 2019 instituted a National Suicide Prevention Day on 10 September but did not create a new holiday.
Moveable feasts — Carnaval, Sexta-feira da Paixão, Corpus Christi — are not formally national holidays under Law 662, but they are observed almost universally by banks and government offices and are treated as holidays for procedural deadlines under article 216 of the Code of Civil Procedure. A correct dias-úteis calculation for Brazil therefore needs an Easter algorithm (Computus) to derive the moveable dates from the year alone.
- 1 Jan — Confraternização Universal
- Carnaval (Monday and Tuesday before Ash Wednesday, moveable)
- Sexta-feira da Paixão (Good Friday, moveable)
- 21 Apr — Tiradentes
- 1 May — Dia do Trabalho
- Corpus Christi (60 days after Easter, moveable)
- 7 Sep — Independência
- 12 Oct — Nossa Senhora Aparecida
- 2 Nov — Finados
- 15 Nov — Proclamação da República
- 20 Nov — Consciência Negra (national since 2024)
- 25 Dec — Natal
The Julian Day Number algorithm
To compute the number of days between two dates robustly, the cleanest trick is to map each calendar date to a single integer and subtract the integers. That integer is the Julian Day Number (JDN), introduced by Joseph Justus Scaliger in 1583 and now standard in astronomy and scientific software. JDN 0 corresponds to noon Universal Time on Monday, 1 January 4713 BC in the proleptic Julian calendar; 1 January 2000 at noon UT is JDN 2 451 545. Every calendar day since then has its own consecutive integer.
The Fliegel and Van Flandern formula converts a Gregorian (Y, M, D) triplet to JDN with only integer arithmetic: JDN = ⌊1461·(Y+4800+⌊(M-14)/12⌋)/4⌋ + ⌊367·(M-2-12·⌊(M-14)/12⌋)/12⌋ - ⌊3·⌊(Y+4900+⌊(M-14)/12⌋)/100⌋/4⌋ + D - 32075. The number of days between two dates is then simply JDNend - JDNstart, which always returns the correct count regardless of months, leap years or century boundaries.
In JavaScript the same effect is usually obtained via Date.UTC(year, month-1, day), which returns milliseconds since 1 January 1970 UTC. Dividing by 86 400 000 yields a continuous day count that behaves like a shifted JDN. The crucial detail is to use UTC throughout: local-time arithmetic breaks at every daylight-saving transition.
Gregorian versus Julian calendar: the 1582 cut
The Julian calendar, introduced by Julius Caesar in 45 BC, assumed a year of exactly 365.25 days and inserted a leap day every four years. The true tropical year is shorter (about 365.2422 days), so the calendar drifted by roughly three days every four centuries. By the 16th century the spring equinox had slipped to 10 March, dragging Easter with it. Pope Gregory XIII corrected the drift in 1582: by the bull Inter gravissimas the day following Thursday 4 October 1582 (Julian) was decreed to be Friday 15 October 1582 (Gregorian). Ten calendar days disappeared, and the leap-year rule was tightened — century years are leap only when divisible by 400.
The reform was adopted unevenly. Catholic states switched in 1582; Protestant Germany and the Netherlands followed in 1700, Britain and its colonies in 1752 (the gap was 11 days by then), Russia only in 1918, Greece in 1923. A historical day counter that crosses any of these national transitions must know which calendar each date is expressed in — otherwise it will be 10 to 13 days off. For everyday work after 1923 you can safely assume Gregorian everywhere.
Legal deadlines in Brazilian procedural and consumer law
Article 219 of the New Code of Civil Procedure (Law 13.105/2015) reversed a long Brazilian tradition: procedural deadlines expressed in days are now counted in business days only. A 15-day appeal window (recurso de apelação) starts on the next business day after publication and runs for 15 business days, jumping over weekends and holidays. Article 224 §1 adds that a deadline ending on a non-business day or during a court recess automatically extends to the following business day. By contrast, deadlines fixed in material law — the seven-day cooling-off period under article 49 of the Consumer Defence Code (Law 8.078/1990), prescription periods in the Civil Code, response windows under labour law — are counted in calendar days, including weekends and holidays.
Labour procedure has its own rule: since 2017 the CLT also counts procedural deadlines in business days (article 775 CLT, amended by Law 13.467/2017). Tax administrative procedure (Decree 70.235/72) keeps the old calendar-day rule unless a specific norm says otherwise. The lesson is unambiguous: never compute a legal deadline without first identifying which regime governs it.
Vacations, leave, contract terms and interest accrual
CLT vacations (article 130) grant 30 calendar days after a 12-month acquisition period; partial absences during that period reduce the entitlement. Maternity leave (article 392 CLT, Law 11.770/2008) is 120 calendar days extendable to 180 under the Empresa Cidadã programme. Sick leave paid by INSS starts on day 16 of the medical absence and continues in calendar days. Lease and service contracts often define their duration in months that the Civil Code (article 132) interprets as ending on the corresponding day of the final month. For consumer credit, the Central Bank requires interest to be quoted as an effective monthly rate; the underlying day count is usually calendar days under the "exact/360" or "exact/365" convention.
Pitfalls: time zones, DST and the civil-year boundary
Three traps recur in day-counting code. First, mixing local time and UTC. A date typed as "2025-03-15" is treated by JavaScript as midnight UTC; rendering it back in São Paulo time (UTC−3) shifts it to 21:00 on the previous day, producing an off-by-one count. Always parse and compute in UTC. Second, daylight saving. Brazil abolished DST in 2019, but interoperability with countries that still observe it (most of Europe, parts of the US) means that a "24 hours" interval can be 23 or 25 hours on transition days; subtracting timestamps in milliseconds can produce non-integer days. Third, the civil-year boundary. Counts that span 31 December must not double-count or skip the leap day of the following year — the JDN approach handles this automatically; ad-hoc subtraction of years, months and days does not.
Frequently asked questions
Does the start date count? By convention, intervals are half-open: the start date is excluded and the end date is included, so 1 Jan to 2 Jan is one day. Brazilian procedural law follows the same rule (article 224 CPC).
Why does my answer change when I cross a leap year? 29 February exists only in leap years (divisible by 4, except century years not divisible by 400). Crossing it adds one calendar day to the count compared with a non-leap range.
How do I count business days that include Brazilian holidays? Build the list of fixed and moveable holidays for each year touched by the interval, then iterate day by day skipping Saturdays, Sundays and any date in that list. Caching the holiday set per year keeps the loop fast.
Are dates before 1582 valid? Yes, but you must decide whether to use the proleptic Gregorian calendar (extends the modern rule backward) or the Julian calendar in effect at the time. Historians prefer Julian for medieval dates; astronomers usually use proleptic Gregorian.
Can I count weeks or months exactly? Weeks are 7 calendar days, so the conversion is exact. Months are not — they range from 28 to 31 days. The convention adopted here is to count whole months between equivalent calendar days (15 Jan to 15 Mar = 2 months) and report the residual days separately.
Count the days between two dates
Counting on the calendar how many days separate two dates is tedious, and the moment the span crosses a month or a year the mistakes creep in. Here the count comes out ready, from the start date through to the end, and you get to decide whether weekends are in or out.
The result doesn't stop at days: you also get the equivalent in weeks and months, so the whole period is laid out for you. It works well for deadlines, contract length, holiday days, the wait until an event or how long ago something happened. And since you can count working days only, it ends up handy at work too.
Pick the two dates and the detailed count appears right away, worked out inside the browser, with nothing leaving your machine.
Read more on this
Related Tools
Date Difference Calculator
Calculate the difference in days, weeks, months and years between two dates. Instant result in the browser.
Subtract Days from Date
Calculate the resulting date when subtracting N days from a date. Instant result with correct leap year handling.
Add Days to Date
Calculate the resulting date when adding N days to a start date. Instant result with correct leap year handling.