I have formula to convert text "2 hours 43 mins" to "2,43". Sometimes value is "1 hour 43 mins" and my current solution does not work in this case. How to make it work in both cases "2 hours 43 mins" and "1 hour 43 mins"? I have tried to use OR with no success.
This is my current formula:
=SUBSTITUTE(SUBSTITUTE(Q68;"mins";"");" hours ";",")
I have tried:
=SUBSTITUTE(SUBSTITUTE(Q68;"mins";"");OR(" hours ";" hour ");",")
Try this:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Q68;"s";"");"min";"");" hour ";",")
How about:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Q68;"min";"");" hour";",");"s";"")
EDIT#1:
The "best approach":
replace "hour"
replace "min"
replace "s"
replace " "
Related
I have a time in a cell, want to minus 2 hrs and add 2hrs to the time and display in excel
Example : 02/08/2020 11:00AM
So Minus 2hrs and plus 2 hrs next cell must display as 9:00AM-13:00PM
I tried the below formula but displays like 43811.0577893518 - 43811.2244560185
=CONCATENATE(A1-TIME(2,0,0)," ","-"," ",A1+TIME(2,0,0))
Subtract & add two hours (2/24) to your date
=TEXT(A1-(2/24),"hh:mm AM/PM") & " - " & TEXT(A1+(2/24), "hh:mm AM/PM")
Use TEXT to format the output:
=CONCATENATE(TEXT(A1-TIME(2,0,0),"HH:MM AM/PM")," ","-"," ",TEXT(A1+TIME(2,0,0),"HH:MM AM/PM"))
Can we put up a OR command for custom time in one column?
I have multiple time formats in one column of excel. For eg:
Timing
30 min
31 sec
4 min 20 sec
1 hr 2 min
3 hr
1 hr 23 min 30 sec
I want to convert it to time format: hh:mm:ss so that i can calculate average from all times. How can I achieve it?
Here's a shorter formula:
=TIME(IF(IFERROR(FIND("hr";$A2);0)=0;0;IFERROR(MID($A2;IFERROR(FIND("hr";$A2);0)-3;2);MID($A2;IFERROR(FIND("hr";$A2);0)-2;1)));IF(IFERROR(FIND("min";$A2);0)=0;0;IFERROR(MID($A2;IFERROR(FIND("min";$A2);0)-3;2);MID($A2;IFERROR(FIND("min";$A2);0)-2;1)));IF(IFERROR(FIND("sec";$A2);0)=0;0;IFERROR(MID($A2;IFERROR(FIND("sec";$A2);0)-3;2);MID($A2;IFERROR(FIND("sec";$A2);0)-2;1))))
Note: the above formula contains semicolon (;) as a separator. Replace with coma (,), in case this is your system separator.
To be honest I did not try to decipher #Foxfire's formula.
Remember to apply custom time format to the result cell: [h]:mm:ss
For explanatory reasons see breakdown of the long formula:
This huge formula worked for me:
=IF(AND(IFERROR(FIND("hr";A1;1);0)>0;IFERROR(FIND("min";A1;1);0)>0;IFERROR(FIND("sec";A1;1);0)>0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1;" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)>0;IFERROR(FIND("min";A1;1);0)>0;IFERROR(FIND("sec";A1;1);0)=0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A1)&" 00 sec";" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)=0;IFERROR(FIND("min";A1;1);0)>0;IFERROR(FIND("sec";A1;1);0)>0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE("00 hr " & TRIM(A1);" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)>0;IFERROR(FIND("min";A1;1);0)=0;IFERROR(FIND("sec";A1;1);0)=0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A1)&"00 min 00 sec";" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)=0;IFERROR(FIND("min";A1;1);0)>0;IFERROR(FIND("sec";A1;1);0)=0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE("00 hr " & TRIM(A1)&" 00 sec";" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)=0;IFERROR(FIND("min";A1;1);0)=0;IFERROR(FIND("sec";A1;1);0)>0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE("00 hr 00 min "&TRIM(A1);" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");"Formula needs to be updated"))))))
As I said, you need to check every string in your text. Depending if it contains hr,min,sec, you need to calculate the time and then convert it to time. Also, you need to take care of those annoying blanks at end of some strings. This formula does all this.
Hope you can adapt this to your needs. My Excel is in spanish, but I translated formulas manually. Just in case I typed wrong, I uploaded a file example to Gdrive for you to download and check the formulas (they should autotranslate if you open it).
https://drive.google.com/open?id=13J5IWLOFFZpzvIp1oqPwqkE3eHDk7EeH
I have a nested if that has
=IF(A1=10,"you have 10 points","otherwise blank",IF(A1=20,"you have 20 points","otherwise blank",IF(A1=30,"you have 30 points","otherwise blank")))
What I want is that if it finds 10,20 or 30 to give those outputs otherwise don't display any output, but I get an error that say
You've entered too many arguments for this function.
How about:
=If(OR(A1=10,A1=20,A1=30),"You have " & A1 & " points","")
Or:
=IF(ISNUMBER(MATCH(A1,{10,20,30},0)),"You have " & A1 & " points","")
Try doing this:
=if(A1=10,"you have 10 points",if(A1=20,"you have 20 points",if(A1=30,"you have 30 points","")))
The logic is as following:
If A1=10, you have 10 points
If not, then if A1=20, you have 20 points
If not, then if A1=30, you have 30 points
If not, then it means A1 does not equal either 10, 20 or 30, so return blank.
Your formula should be something like this:
=IF(OR(A1=10,A1=20, A1=30), A1, "")
I have a two dates in excel "1/2/2016 01:56:05" and "8/3/2016 06:21:46". How do I calculate the time difference between them in a format of days and hours?
Thanks!
Try this to include the spelled out hours and minutes:
=INT(A2-A1) & " days, " & TEXT(A2-A1,"h "" hours, ""m "" minutes""")
Note that since the m comes immediately (ignoring the separator text in quotes) after the h it will be interpreted as minutes and not months
I prefer to work with dates as decimals. It looks cumbersome, but I'm much happier knowing what it's doing.
What I would usually do is to have A1-A2 in cell A3, then work out the component parts separately:
Days: =INT(A3)
Hours: =INT((A3-INT(A3))*24)
Minutes: =INT(((A3*24)-INT(A3*24))*60)
Or if you wanted to do it all in one formula:
=INT(A3)&" days, "&INT((A3-INT(A3))*24)&" hours, "&INT(((A3*24)-INT(A3*24))*60)&" min"
or without using A3
=INT(A1-A2)&" days, "&INT(((A1-A2)-INT(A1-A2))*24)&" hours, "&INT((((A1-A2)*24)-INT((A1-A2)*24))*60)&" min"
It's not the prettiest or most efficient method but you can see how the times are calculated this way.
Assuming the dates are in cells A1 and A2, this will produce an answer with minutes as well in d:hh:mm format.
=INT(A2-A1) & ":" & TEXT(A2-A1,"hh:mm")
Drop the :mm if you don't need minutes.
If you want text:
=INT(A2-A1) & " days, " & TEXT(A2-A1,"h") & " hours"
If you want text with minutes:
=INT(A2-A1) & " days, " & TEXT(A2-A1,"h"" hours, ""m"" minutes""")
Using double quotes alongside each other "escapes" the quote itself and allows the extra text to appear in the string. As Ron stated in his answer, the m following an h in the same format string indicates minutes, so you can save an extra A2-A1 calculation by putting both in a single format.
I am facing a problem with excel.How can I convert DD:HH:MM to HH:MM in excel?
Here is an exmaple showcasing what I need.
1:02:49(1day, 2hours, 49 mins) should come as 26:49(26 hours, 49 min)
I'm guessing that your 1:02:49 cell is formatted as text; otherwise, you could just change the cell format from DD:HH:MM to HH:MM.
I've opted to output as text, but could change it to an actual Time value if needbe.
Yes, the formula is a bit long but it can cope with any number of digits between each :. So, for example, 100:3:4 (100 days, 3 hours, 4 minutes) would correctly evaluate to 2403:04
=24*LEFT(A1,FIND(":",A1)-1)+MID(A1,FIND(":",A1)+1,LEN(A1)-2-LEN(RIGHT(A1,LEN(A1)-FIND("#",SUBSTITUTE(A1,":","#",2))))-LEN(LEFT(A1,FIND(":",A1)-1)))&":"&TEXT(RIGHT(A1,LEN(A1)-FIND("#",SUBSTITUTE(A1,":","#",2))),"00")