Date formula not working as intended

suciulaurentiu

New Member
Joined
Oct 20, 2014
Messages
37
Office Version
  1. 365
Platform
  1. Windows
Hello,
I have the following question regarding the formula and what I am trying to achieve:

Start_Date , End_date
months_interval = one number of random months (ex. 48)

Start_Date - Today (ex. 01.11.2021)
End_date - =IFERROR(EDATE((EDATE(Start_date;months_interval))-1;1);""))

I am trying here to calculate the end date by adding some months interval and the day should -1 day of the result ( we should have to count even for the february months, if it's a leap year or not...)

Ex: Start : 01.12.2021 End: 31.12.2023
Start: 05.12.2021 End: 04.01.2024

Right now my end result is: Start : 01.12.2021 End: 30.12.2023 not sure what is wrong..
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Couldn't you just use:

=DATE(YEAR(Start_Date);MONTH(Start_Date)+months_interval;Day(Start_Date)-1)
 
Upvote 0
It's actually probably safer to use:

Excel Formula:
=DATE(YEAR(Start_Date);MONTH(Start_Date)+months_interval;Day(Start_Date))-1

I suggest you test it with a variety of dates to make sure it returns the results you want.
 
Upvote 0
Hi,
I still have errors with the formula , if today is 31.01.2022 i get 02.03.2025 instead of 28.02.2025. I don`t know what is wrong, please help! I really appreciate any input on this!
Just to remember in the initial post:

Start_Date , End_date
months_interval = one number of random months (ex. 48)

Start_Date - Today (ex. 01.11.2021)
End_date - =IFERROR(EDATE((EDATE(Start_date;months_interval))-1;1);""))

I am trying here to calculate the end date by adding some months interval and the day should -1 day of the result ( we should have to count even for the february months, if it's a leap year or not...)

Ex: Start : 01.12.2021 End: 31.12.2023
Start: 05.12.2021 End: 04.01.2024

If random months is ex. 24 it calculates fine, if it goes over 36, than the year changes and I get a wrong date again...
 
Upvote 0
31.01.20221202.03.20232030.10.20233130.09.20244130.07.20258130.11.2028
1330.03.20232130.11.20233230.10.20244230.08.20258230.12.2028
1430.04.20232230.12.20233330.11.20244330.09.20258330.01.2029
1530.05.20232330.01.20243430.12.20244430.10.20258402.03.2029
1630.06.20232401.03.20243530.01.20254530.11.2025
1730.07.20232530.03.20243602.03.20254630.12.2025
1830.08.20232630.04.20243730.03.20254730.01.2026
1930.09.20232730.05.20243830.04.20254802.03.2026
2830.06.20243930.05.20254930.03.2026
2930.07.20244030.06.20255030.04.2026
3030.08.2024
5130.05.20266130.03.20277130.01.2028
5230.06.20266230.04.20277201.03.2028
5330.07.20266330.05.20277330.03.2028
5430.08.20266430.06.20277430.04.2028
5530.09.20266530.07.20277530.05.2028
5630.10.20266630.08.20277630.06.2028
5730.11.20266730.09.20277730.07.2028
5830.12.20266830.10.20277830.08.2028
5930.01.20276930.11.20277930.09.2028
6002.03.20277030.12.20278030.10.2028
 
Upvote 0
The reason is that the formula adds 37 full months in your example, which takes it technically to the 31st of Feb 2025. Since the last day of Feb is the 28th, the 31st is really the 3rd of March. Subtracting 1 from that is then the 2nd March. Why should it be the 1st?
 
Upvote 0
@RoryA, thank you for the quick input! I should have for today, the end date of : 28.02.2025, and of course all the end dates that goes with it...currently my formula ends me up in 02.03.2025
 
Upvote 0
If you just want the end of the relevant month, why can't you just use EOMONTH and not subtract 1?
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,812
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top