SOLVED

Convert string to number of days

Copper Contributor

Please share excel formula to convert- "

1 years 0 months 22 days = "387" days 

 

5 Replies

@arjsharm I guess it depends which year you are talking about. Some years have 364 days, some have 365 days. So, it will be either 365 + 22 or 364 + 22.

best response confirmed by arjsharm (Copper Contributor)
Solution

Hello @arjsharm,

 

If "years", "months", and "days" are in the same cell such as "1 years 0 months 22 days" then that could be:

=SUM(365*LEFT(A1,FIND(" y",A1)-1),365/12*MID(A1,FIND("rs",A1)+3,FIND(" m",A1)-FIND("rs",A1)-3),--MID(A1,FIND("hs",A1)+3,FIND(" d",A1)-FIND("hs",A1)-3))&" days"

 If "years", "months", and "days" are in the separate cells such as

YearsMonths

Days

1022

Then that could be:

=A1*365+B1*365/12+C1&" days"

@Riny_van_Eekelen in my case the year is 365 days irrespective of leap year days 

@PReagan Thanks for sharing the formula ! It worked!

 

@arjsharm 

 

My pleasure!

1 best response

Accepted Solutions
best response confirmed by arjsharm (Copper Contributor)
Solution

Hello @arjsharm,

 

If "years", "months", and "days" are in the same cell such as "1 years 0 months 22 days" then that could be:

=SUM(365*LEFT(A1,FIND(" y",A1)-1),365/12*MID(A1,FIND("rs",A1)+3,FIND(" m",A1)-FIND("rs",A1)-3),--MID(A1,FIND("hs",A1)+3,FIND(" d",A1)-FIND("hs",A1)-3))&" days"

 If "years", "months", and "days" are in the separate cells such as

YearsMonths

Days

1022

Then that could be:

=A1*365+B1*365/12+C1&" days"

View solution in original post