SOLVED

Need help in modifying the time column

Copper Contributor

Hi everyone I'm trying to solve a problem with a time column which I believe is formatted as text in excel column. It has data for minutes and seconds in a single column as shown in the snapshot below. Can someone please help me solve this problem? I want the column to have data in seconds. If anyone could bring out a solution for this, it would be great. 
I am attaching the snapshot below for reference. Excel time conversion.jpeg

 

Thanks in advance

6 Replies

@Satishbadiger3 Perhaps not the most elegant solution, but a quick-and-dirty one.

=IFERROR(LEFT(J2,IFERROR(FIND("m",J2),0)-1)*60,0)+MID(J2,IFERROR(FIND("m",J2),0)+1,LEN(J2)-IFERROR(FIND("m",J2),0)-1)

Quite a bit of repetition that you could eliminate if your Excel version supports the LET function. 

@Riny_van_Eekelen fantastic, this works!! Thanks a ton


Can you also give out the formula using LET, it would be great if you could do the needful. 

You could also try the relatively new TEXTBEFORE and TEXTAFTER
=IFERROR(TEXTBEFORE(J2,"m")*60,0)+IFERROR(TEXTBEFORE(J2,"s")*1,TEXTAFTER(TEXTBEFORE(J2,"s"),"m")*1)

 

***ED***

You need to handle a time with only minutes to

2m

=IFERROR(TEXTBEFORE(J2,"m")*60,0)+IFERROR(TEXTBEFORE(J2,"s")*1,IFERROR(TEXTAFTER(TEXTBEFORE(J2,"s"),"m")*1;0))

 

***ED2***

I forgot about TEXTSPLIT

Add "m" to the start of the string (if its missing), remove "s" and split the string with "m" as delimiter.

=TEXTSPLIT(SUBSTITUTE(IF(ISERROR(SEARCH("m",j2)),"m","")&j2,"s",""),"m")

Then multiply minutes with 60 and seconds with 1 (and handle errors)

=SUM(IFERROR(TEXTSPLIT(SUBSTITUTE(IF(ISERROR(SEARCH("m",j2)),"m","")&j2,"s",""),"m")*{60,1},0))

Yeeeah, that's simpler, or not...

***/ED***

 

best response confirmed by Hans Vogelaar (MVP)
Solution

@Satishbadiger3 That could be:

=LET(
    minpos,IFERROR(FIND("m",J2),0),
    IFERROR(LEFT(J2,minpos-1)*60,0)+MID(J2,minpos+1,LEN(J2)-minpos-1)
)

 

You'll note that you define the finding of "m" once, give it a meaningful name like "minpos" and then use that name in the formula.

 

If your Excel supports LET, you could use the new TEXT functions as suggested by @MindreVetande , but the formula will not be much shorter.

Thank you so much Riny!
Thanks for the response! Got to learn so many methods.
1 best response

Accepted Solutions
best response confirmed by Hans Vogelaar (MVP)
Solution

@Satishbadiger3 That could be:

=LET(
    minpos,IFERROR(FIND("m",J2),0),
    IFERROR(LEFT(J2,minpos-1)*60,0)+MID(J2,minpos+1,LEN(J2)-minpos-1)
)

 

You'll note that you define the finding of "m" once, give it a meaningful name like "minpos" and then use that name in the formula.

 

If your Excel supports LET, you could use the new TEXT functions as suggested by @MindreVetande , but the formula will not be much shorter.

View solution in original post