Mike Satterfield
asked on
Looking for an Excel formula to convert time.
I have a report in excel where the total time is written like so:
100d2h54min29s
I was wondering / hoping someone had a formala to confert that data into a straight number of seconds.
IE:
8650469
Thank you,
100d2h54min29s
I was wondering / hoping someone had a formala to confert that data into a straight number of seconds.
IE:
8650469
Thank you,
It would be easy to do that with the help of VBA. Are you open to a VBA solution to have a User Defined Function which you can either use in macros or on the worksheet itself as a regular formula?
ASKER
Yes i would be open to that.
What happens to the string if an element is zero?
Does it still show in the string, eg 0h or will that element be omitted?
Does it still show in the string, eg 0h or will that element be omitted?
Try this formula, where string is in A4:
=MID(A4,1,FIND("d",A4,1)-1 )*86400+MI D(A4,FIND( "d",A4,1)+ 1,FIND("h" ,A4,1)-FIN D("d",A4,1 )-1)*3600+ MID(A4,FIN D("h",A4,1 )+1,FIND(" m",A4,1)-F IND("h",A4 ,1)-1)*60+ MID(A4,FIN D("m",A4,1 )+3,2)*1
Assumes elements with zero value will still be included.
=MID(A4,1,FIND("d",A4,1)-1
Assumes elements with zero value will still be included.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Assuming that d, min and h are all present, you may use:
=86400*(LEFT(A2,SEARCH("d",A2)-1)+SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(MID(A2,SEARCH("d",A2)+1,99),"h",":"),"min",":"),"s",""))
@byundt - nice logic, convert the days and then convert the remaining string into a proper time stamp.
ASKER
Thank everyone who participated!
I really appreciate the assistance.
I really appreciate the assistance.
Glad to help, can you confirm whether the string will have all elements even if 0 value?
If the elements will still be included, even if zero, then the formula options would work. If not then you are right to choose the UDF option from Neeraj as the formula options would not work or would give incorrect result in those cases.
If the elements will still be included, even if zero, then the formula options would work. If not then you are right to choose the UDF option from Neeraj as the formula options would not work or would give incorrect result in those cases.
You're welcome Mike! Glad I could help.