Is there a formula to calculate years, months, and days between 2 different dates?
I found a formula that calculates the years and months between 2 different dates, but because it's not also calculating the days, it is rounding up the months which isn't going to work in the case that I need it.
Here is a picture of what I'm looking for (how many years, months, and days) Purchase Date to Expiration Date.
The formula that I'm currently using is:
=ROUND(ROUND((NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365) * 12) / 12) + "yrs" + MOD(ROUND((NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365) * 12), 12) + "mo"
Please let me know if I'm missing something to be able to also add in the day count!
Thank you
Answers
-
Not sure if you are going to get it perfect down to the day. I tried adding three helper columns and came up close.
Years =NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24
Months =VALUE(RIGHT(Years@row, LEN(Years@row) - (FIND(".", Years@row)) + 1)) * 12
Days =VALUE(RIGHT(Months@row, LEN(Months@row) - (FIND(".", Months@row)) + 1)) * 30.437
Date Run Count =LEFT(Years@row, FIND(".", Years@row) - 1) + "yrs " + LEFT(Months@row, FIND(".", Months@row) - 1) + "mo " + LEFT(Days@row, FIND(".", Days@row) - 1) + "days "
-
@Paul H thank you for looking into this! Do you know if there might be a way to do it without the helper columns? If not, no worries--just wanted to check!
-
=LEFT(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24, FIND(".", NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24) - 1) + "yrs " + LEFT(VALUE(RIGHT(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24, LEN(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24) - (FIND(".", NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24)) + 1)) * 12, FIND(".", VALUE(RIGHT(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24, LEN(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24) - (FIND(".", NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24)) + 1)) * 12) - 1) + "mo " + LEFT(VALUE(RIGHT(VALUE(RIGHT(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24, LEN(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24) - (FIND(".", NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24)) + 1)) * 12, LEN(VALUE(RIGHT(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24, LEN(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24) - (FIND(".", NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24)) + 1)) * 12) - (FIND(".", VALUE(RIGHT(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24, LEN(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24) - (FIND(".", NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24)) + 1)) * 12)) + 1)) * 30.437, FIND(".", VALUE(RIGHT(VALUE(RIGHT(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24, LEN(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24) - (FIND(".", NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24)) + 1)) * 12, LEN(VALUE(RIGHT(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24, LEN(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24) - (FIND(".", NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24)) + 1)) * 12) - (FIND(".", VALUE(RIGHT(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24, LEN(NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24) - (FIND(".", NETDAYS([Purchase Date]@row, [Expiration Date]@row) / 365.24)) + 1)) * 12)) + 1)) * 30.437) - 1) + "days "
-
@Paul H thank you so much!!!
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 140 Industry Talk
- 472 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 496 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!