ユーティリティ

Date Calculator: Add or Subtract Days, Months, and Years

How date arithmetic works -- adding days, months, or years to a date, month-end rules, and day-of-week determination. With worked examples.

Verified against ISO 8601 - Date and Time Representations on 20 Feb 2025 Updated 20 February 2025 4 min read
計算ツールを開く

Translation unavailable - this article is shown in English. View English version

Summary

Date arithmetic answers the question “what date is N days/months/years from a given date?” While adding days is conceptually straightforward (each day advances by one), adding months or years introduces complications because months have different lengths and leap years change February. This calculator handles all of these edge cases and also tells you the day of the week for the resulting date.

How it works

The calculator supports three operations:

  1. Add/subtract days — advances or retreats by an exact number of calendar days. This is unambiguous because a day is always exactly one day.
  2. Add/subtract months — advances the month number. If the resulting day exceeds the new month’s length, it is capped (e.g., January 31 + 1 month = February 28 in a non-leap year).
  3. Add/subtract years — advances the year. The only edge case is February 29 in a leap year: adding 1 year lands on February 28 if the target year is not a leap year.

Day-of-week calculation

The day of the week for any date can be computed algorithmically. Zeller’s congruence and the Doomsday algorithm are two well-known methods. Modern implementations typically use the Julian Day Number modulo 7.

The formulas

result_date = start_date + N days

Where

start_date= The starting calendar date
N= Number of days to add (negative to subtract)
result_date= The resulting calendar date
Day of week = (JDN mod 7) maps to {Mon, Tue, Wed, Thu, Fri, Sat, Sun}

Where

JDN= Julian Day Number of the date
mod 7= Remainder when divided by 7 (the week cycle)

Worked examples

What date is 90 days after January 1, 2025?

1

Days remaining in January

31 - 1 = 30 days (Jan 2 through Jan 31)

= 30 days used, 60 remaining

2

All of February 2025 (not a leap year)

28 days

= 58 days used, 32 remaining

3

Remaining days in March

31 days of March (but only 32 remain)

= 89 days used, 1 remaining

4

Into April

April 1

= 90 days used

Result

90 days after Jan 1, 2025 = April 1, 2025 (Tuesday)

January 31 + 1 month

1

Advance month from January to February

Target: February 31

= February 31 does not exist

2

Cap at month's last day

February has 28 days (non-leap year)

= February 28

Result

January 31 + 1 month = February 28 (month-end capping rule)

February 29, 2024 + 1 year

1

Advance year from 2024 to 2025

Target: February 29, 2025

= 2025 is not a leap year

2

Cap at month's last day

February 2025 has 28 days

= February 28, 2025

Result

Feb 29, 2024 + 1 year = Feb 28, 2025

Practical uses

  • Deadline calculation — “your payment is due 30 days from the invoice date” or “the warranty expires 2 years from purchase.”
  • Scheduling — finding the date for a meeting “3 months from today” or determining when a subscription renews.
  • Travel planning — counting days to determine check-in/check-out dates, visa duration, or trip length.
  • Legal and financial — notice periods, grace periods, and maturity dates are specified as offsets from a reference date.

Assumptions & limitations

  • Month-end capping — adding 1 month to January 31 gives February 28 (or 29). This means date arithmetic is not always reversible: Jan 31 + 1 month - 1 month = Jan 28, not Jan 31.
  • No business days — the calculator counts calendar days. For business-day calculations (excluding weekends and holidays), a dedicated business day calculator is needed.
  • Gregorian calendar — all calculations assume the Gregorian calendar. The calculator does not handle Julian calendar dates or historical calendar transitions.
  • Single timezone — the result is a calendar date without timezone context. Crossing timezones or daylight saving transitions could shift the perceived date.

出典

Industry
date-calculator date-arithmetic add-days calendar day-of-week utility