I have a series of different date ranges separated by underscore. These dates are textwrapped inside a single excel cell so they appear on different lines. Please see sample details below:
CELL B2
----------------------------
| 06/13/2019 - 09/01/2019_ |
| 06/21/2021 - 08/29/2021_ |
| 08/22/2022 - 11/30/2022_ |
| 06/30/2023 - 07/28/2023_ |
| 10/03/2023 - 11/30/2023 |
----------------------------
This is the excel TEXTSPLIT I am using =IFERROR(TEXTSPLIT(C2,,"_"),"")
and the result is this:
CELL C
----------------------------
2| 06/13/2019 - 09/01/2019_ |
----------------------------
3| 06/21/2021 - 08/29/2021_ |
----------------------------
4| 08/22/2022 - 11/30/2022_ |
----------------------------
5| 06/30/2023 - 07/28/2023_ |
----------------------------
6| 10/03/2023 - 11/30/2023 |
----------------------------
I need to compute each DATEDIF
but only the CELL C2 appeared to have a result. Let’s say 2 Months. Here is the formula I am using:
CELL D2
=IFERROR(DATEDIF(IFERROR(LEFT(C2,SEARCH(" - ",C2)-1),""),IFERROR(RIGHT(C2,SEARCH(" - ",C2)-1),""),"YM"),"")&" Months"
The rest return nothing since the value is error.
I have tried to search online but no solutions were found.
Thank you for the help.
JeffLiteral is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.