I am looking to take the hyphen or dash out of a birthdate.
01/01/01
01-01-01
I need to combine the birthdate with other fields and it can't have the seperator in it.
I am sure there is a better way. I can get the month and year out, using left & right however I can't figure out how to get the middle out. Below is what I have so far and I know that I can combine them using "&"...if someone can help me with the middle or give me a better equation I would appreciate it.
LEFT(A1,2)
RIGHT(A1,2)
Solution:
=LEFT(F2,2)&MID(F2,4,2)&RIGHT(F2,4)
if it is a string, (not formated as a date) then you can use
MID(A1,4,2)
otherwise i just use the MONTH(A1) DAY(A1) YEAR(A1) functions
I'm not sure what an excel formula is so this answer might be irrelevant...
VBA has a Mid function that would do what you want I believe. This page has good explanations for that and the other similar functions: http://www.vbtutor.net/VBA/vba9.htm
You could also do a Find and Replace to replace the "-" with nothing.
Ctrl + H will bring up the Replace dialog box.
Change the number format of the date to something line "mmddyy". To combine it with other text in another cell, use a formula like:
="The date is "&TEXT(A1,"mmddyy")
where the date is in cell A1.
Related
I have a problem with an excel file.
I am trying to extract information from a column. This information appears randomly, before a ".", "-" or ":". So an example would be:
CELL
EXPECTED RESULT
hi.this is:
hi
maybe I- this works
maybe I
Who is: what. like-
Who is
I am using the formula:
=MID(A1,1,FIND("-",A1,1)-1)
Using this one, I get the information I need, but I am not able to add the other characters (".", ":",...) to the formula. Also I have the problem that in a same cell, I can have several of this characters, and I only want the information before the FIRST character (of all posible kinds) that appears in the cell.
I dont know if somebody can help me here.
Thank you very much in advance!
You can try:
Formula in B1:
=TEXTBEFORE(A1:A3,{".","-",":"})
If you don't yet have acces to TEXTBEFORE() then try:
=LEFT(A1,MIN(FIND({".","-",":"},A1&".-:"))-1)
I suppose this is an array-entered formula in versions prior to ms365.
I am attempting to split a percentage using excel formulas. I am trying to get the first portion of the percent before the "-" and the second portion of the percent after the "-".
L16 = 1-7% will cause this to work perfect fine.
L16 = 19-100% will cause the formula to break. I cannot seem to figure out how to get the second portion to work.
I have created 2 formulas.
Grabs first half:
=LEFT(L16,SEARCH("-",L16,1)-1)
Grabs second half(the one not working):
=LEFT(RIGHT(L16,SEARCH("-",L16,1)+0),LEN(RIGHT(L16,SEARCH("-",L16,1)+0))-1)
You can use SUBSTITUTE() for a quick solution:
For the left part:
=LEFT(E2,SEARCH("-",E2)-1)
and the right:
=SUBSTITUTE(RIGHT(E2,LEN(E2)-SEARCH("-",E2)),"%","")
=SUBSTITUTE(RIGHT(L16,LEN(L16)-SEARCH("-",L16)),"%","")
Use this one formula for both:
=--TRIM(MID(SUBSTITUTE(SUBSTITUTE($L16,"%",""),"-",REPT(" ",999)),(COLUMN(A1)-1)*999+1,999))
Put that in the first cell and copy over one and down the data set
And if you want them as percentages then use this:
=--(TRIM(MID(SUBSTITUTE(SUBSTITUTE($L16,"%",""),"-",REPT(" ",999)),(COLUMN(A1)-1)*999+1,999)) & "%")
And format the cells as percentages.
When I copied your formula it worked for me, but then I realized that I put a space on either side of the hyphen. So there is something about the spaces that makes it work, in case that helps you troubleshoot how to fix your formula (I'd leave this as a comment if I had enough rep, sorry).
I have a SharePoint calculated column that is as follows:
=RIGHT(Hip,LEN(Hip)-INT(FIND("-",Hip)))
Basically what this does is return the last digits after the "-" in a string, but for strings that do not contain a "-" it returns #Name? into the column. Does anyone know of an easy way to change this formula to make it say what I want? Or is it just easier to re-think the formula all together. Thanks guys.
You need to use an =IF() statement around this if you're using hyphens that may or may not be there. IF(check for hyphen, hyphen formula, non-hyphen formula), The MSDN information is here for the full docs.
Thanks Graham, I appreciate your time. Your thoughts were definitely helpful! Here is the final solution -
=IF(ISNUMBER(FIND("-",Shipprod)),RIGHT(Shipprod,LEN(Shipprod)-INT(FIND("-",Shipprod))),"Not OK")
I have dates within a cell using this format: (February 13 2014).
When I try to use "WEEKDAY(C2)" I get #VALUE!
I have no idea how to fix this and I need some help to finish this web scraping project. Any ideas?
The problem is that the date is a string, and not a real Excel date formatted as you show. The WEEKDAY function needs have a "real Excel date" as its argument, not a string.
If the apparent spaces between the date components are spaces, then the following formula should work:
=WEEKDAY(--SUBSTITUTE(C5," ",", ",2))
EDIT: As David Zemens just pointed out, the double unary seems to be unnecessary with the weekday function. So
=WEEKDAY(SUBSTITUTE(C5," ",", ",2))
should be a better solution.
If they are something else, the formula would be different, but the principal would be similar
Another method: You may be able to convert it to a "real date" by using the Text to columns wizard, but DON't split it on anything. (You can do that by selecting something like TAB as the delimiter; since there are not tabs, no splitting). When you get to step 3, merely check that it is a date in MDY format. That wizard is pretty smart. Then you can use the WEEKDAY function directly.
One way to do so... maybe not best since it involves adding so many rows
Add a fresh column D and E if not available..
Then use Text to Columns on Column C, with space as delimiter... (This will split column on spaces into 3 columns)
Add a new Column D with formula
=MONTH(C3&1)
Make sure new Column D is of type General or Number rather than Date
Then you can use the following formula
=DATE(F3,D3,E3)
Formula only:
=WEEKDAY(DATE(RIGHT(C2,4),MONTH(LEFT(C2,FIND(" ",C2)-1)&1),(MID(C2,FIND(" ",C2)+1,2))))
with thanks to #tgeery.
Your dates are not in the correct format.
WEEKDAY(DATE(2014,2,13))
should work because the argument for the weekday function needs to come from the DATE function.
I have a cell A1 with 00:40. I would like to write a formulae to recognise this as a hh:mm.
Apparently this formulae does not work: =if(A1="00:40",1,0). I get the result as 0, not 1. Is there anyway to get this excel formulae to return as 1?
I have other cells A2=00:42, A3=text, A4=00.50, A6=text, and A7=00.55. Is it possible to have a formulae to extract only the times and ignore the rest?
According to the comment you added on JDunkerley's answer, here is what you can try:
=MID(A1,FIND(":",A1)-2,5)
This will return some text.
Note that you could also use the TIMEVALUE function to convert this to a time (using LEFT and RIGHT to extract hours and minutes).
Try:
=If(TEXT(A1,"hh:mm")="00:40",1,0)
Simple fix, append +0 to the time
=if(A1="00:40"+0,1,0)
Put an apostrophe before the text.
Eg '00:40
In speadsheet formulae, you can use TIMEVALUE() :
IF(A1=TIMEVALUE("00:40"),1,0)
In VBA, just use the standard time separator: #:
If range("A1") = #00:40# then