Date Calculator by Months: How It Works
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
A date calculator by months works out a new date by adding or subtracting a set number of months from a starting date, or it counts the whole months between two dates. You enter a start date and a number of months (or two dates), and the calculator returns the resulting date or the month count. The key detail is how it handles months of different lengths, which is where most mistakes happen.
Formula
The standard rule for adding months is: take the starting date, add the number of months to the month number, and keep the same day-of-month. If that day does not exist in the target month (e.g., April 31), the date is clamped to the last day of that month. The formula is:
Result = clamp( Year(start) + floor((Month(start) + months – 1) / 12), (Month(start) + months – 1) mod 12 + 1, Day(start) )
Where clamp means: if Day(start) is greater than the number of days in the target month, use the last day of that month instead. For counting whole months between two dates, the formula is: (Year2 – Year1) * 12 + (Month2 – Month1) – (1 if Day2 < Day1 else 0).
Worked Example
Using the default values: start date = 2024-01-31, months to add = 1.
- Target month = January + 1 = February 2024.
- Day of month = 31, but February 2024 has only 29 days (leap year).
- Clamp to last day of February: 2024-02-29.
So the result is 2024-02-29. The calculator shows the same result. Notice that adding 1 month to January 31 gives February 29, not March 2 – a common point of confusion.
When to Use a Month-Based Date Calculator
Month-based date math is common in everyday planning:
- Subscription renewals – “3 months free� means the renewal date is 3 months from signup, not 90 days later.
- Billing cycles – credit card statements are often monthly, not every 30 days.
- Project milestones – “review in 6 months� is a calendar month addition, not 180 days.
- Legal or contractual periods – many contracts specify “months� rather than days.
- Personal reminders – “follow up in 2 months� is easier to track with a calendar.
If the period is defined as “90 days� or “12 weeks�, use a day-based calculator instead. Month-based is for calendar months.
How to Read the Result
The result date is the exact calendar date after adding or subtracting the given number of months. If the day was clamped (e.g., Jan 31 + 1 month = Feb 29), the result is the last day of the target month. That means adding 1 month to Jan 31 and then adding 1 month again gives Feb 29 + 1 month = Mar 29, not Mar 31. This is the standard behavior in most spreadsheet software and programming libraries, but it surprises many people.
When counting months between two dates, the result is a whole number. For example, from Jan 31 to Feb 28 is 1 month (because Feb 28 is the last day of February, and the clamp rule makes it equivalent to Jan 31). From Jan 31 to Mar 30 is 2 months (Jan 31 to Feb 29 = 1, to Mar 30 = 2), but from Jan 31 to Mar 31 is exactly 2 months.
Common Mistakes and Misconceptions
- Treating a month as 30 days: A month is not a fixed length. Adding 1 month to February 1 gives March 1, which is 28 or 29 days later, not 30.
- Ignoring leap years: February 2024 has 29 days, so Jan 31 + 1 month = Feb 29. In a non-leap year, it would be Feb 28.
- Expecting reverse symmetry: Adding 1 month to Jan 31 gives Feb 29, but subtracting 1 month from Feb 29 gives Jan 29, not Jan 31. The clamp rule is not reversible.
- Counting the start day: When counting months between Jan 15 and Mar 15, the answer is 2 months, not 3. The start day is not counted.
- Using day-based math for month periods: 3 months is not 90 days. From Dec 1 to Mar 1 is 3 months but only 90 days (in a non-leap year), while from Mar 1 to Jun 1 is 92 days.
Limits of the Month Calculation
The formula assumes the Gregorian calendar, which is the standard in most of the world. It does not account for business days, holidays, or time zones. It also does not handle “end of month� rules that some financial contracts use, such as “the last business day of the month� or “the same day as the original invoice, but if that day falls on a weekend, move to the next business day.� Those require additional rules.
For dates before 1582 (when the Gregorian calendar was introduced) or in regions that adopted it later, historical dates may differ. The calculator is designed for modern dates.
How to Choose the Right Calculator
If you need to know “what date is 6 months from today?�, use a month-based calculator. If you need “what date is 90 days from today?�, use a day-based calculator. If you need to know how many months between two dates, use the month-count feature. Some calculators offer both. Check whether the calculator clamps the day or rolls over to the next month – the two common behaviors are clamping (Jan 31 + 1 month = Feb 28/29) and rolling over (Jan 31 + 1 month = Mar 2 or Mar 3). Most standard software uses clamping, but always verify with a known example.
Frequently Asked Questions
What does “add 1 month� mean if the start date is January 31?
It means February 28 (or February 29 in a leap year), because February does not have a 31st day. The result is clamped to the last day of February. This is the standard behavior in Excel, Google Sheets, and most programming languages.
Why does adding 1 month to January 31 give February 29, but subtracting 1 month from February 29 gives January 29?
Because the clamp rule is not symmetric. When you add, you clamp to the target month’s last day. When you subtract, you take the day of the start date (29) and find that day in the previous month (January 29 exists). The original January 31 is lost.
How many months are between January 31 and February 28?
Exactly 1 month. Since February 28 is the last day of February, it is treated as the equivalent of January 31 (the last day of January). This is the same rule that makes “1 month after Jan 31� equal to Feb 28.
Is 3 months the same as 90 days?
No. Three calendar months can be 89, 90, 91, or 92 days, depending on the months involved. For example, February to May in a non-leap year is 89 days (Feb 1 to May 1), while March to June is 92 days. Always use a day-based calculator if the period is defined in days.
What is the difference between “months between� and “months added�?
“Months between� counts whole calendar months between two dates, ignoring the day if it is earlier. “Months added� produces a new date by adding a number of months to a start date. The two are related but not identical: adding 2 months to Jan 31 gives Mar 31, but the months between Jan 31 and Mar 31 is 2.
Does the calculator account for leap years?
Yes. The calculator uses the actual number of days in each month for the given year, so February 2024 has 29 days. This affects the clamp rule and any month-count that crosses February 29.
Related
Formula used
in start | Start date | yyyy-mm-dd | 2024-01-31 | 0 in months | Months to add | months | 1 | 0 out result | Result date | date | add_months(start, months) | 0 out same_day | Day of month preserved? | - | (day(start) == day(result)) ? 1 : 0 | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.