Feb 16 2023 12:16 AM
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.
Thanks in advance
Feb 16 2023 02:10 AM
@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.
Feb 16 2023 04:56 AM
@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.
Feb 16 2023 05:22 AM - edited Feb 16 2023 05:50 AM
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***
Feb 16 2023 05:37 AM
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.
Feb 17 2023 02:39 AM
Feb 16 2023 05:37 AM
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.