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
- Smartsheet Customer Resources
- 64K Get Help
- 410 Global Discussions
- 220 Industry Talk
- 459 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 137 Just for fun
- 57 Community Job Board
- 459 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 298 Events
- 37 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!