I tried to convert a date 1130505 to excel date format 5/5/2013, I first converted it by "=19000000+1130505"(20130505) in B2, then use =TEXT(B2,"yyyy-mm-dd") but it gave me an error. Anyone knows why?
It is looking for a number in the excel date notation. i.e. (see below) if you put in the date 8/7/2013 the excel "value" of that is 41493 for which the =TEXT(B6,"yyyy-mm-dd") formula would work.
Since you've already got the date formatted you don't want excel to do any thinking so you want to use =TEXT(B2,"####-##-##")
Excel has values for dates that don't equate to the numbers concatenated, so unfortunately the "TEXT" formula isn't going to work.
My recommendation would be to use a combination of "CONCATENATE", "RIGHT", and "LEFT" functions. In this case, you'd write:
=CONCATENATE(LEFT(RIGHT(A2,4),2),"/",RIGHT(A2,2),"/",RIGHT(LEFT(A2,3),2))
It looks a bit complicated, but it's the only way I can think of to handle the ordering in your values and that leading "1".
With data in A1, in B1 enter:
=DATE(2000+MID(A1,2,2),MID(A1,4,2),RIGHT(A1,2))
Then you can format B1 (if you need a true date):
or you can use:
=TEXT(DATE(2000+MID(A1,2,2),MID(A1,4,2),RIGHT(A1,2)),"m/d/yyyy")
if you need a text result.
Related
Im exploring how feasible it is to extract data from cells that consist of text. ultimately. I will apply conditional formatting rules based on the date relative to today, but right now I just need to be able to extract them.
So far I have achieved the following:
To achieve this I've used the formula found online =IFERROR(DATEVALUE(LEFT(RIGHT(B2,(LEN(B2)-(FIND("-",B2)-3))),11)),""). The issue is that if a cell contains only a date, the Length is subtracted from itself and nothing is returned. I have tried modifying the above equation but keep running into errors.
Hoping someone may be able to help me out modify this formula. Alternatively, if anyone knows how dates can be extracted used just excel formulas that would be great.
The issue is that without the other text it is a true date and a true date is a double and has no - in it.
The simple fix is to wrap change the"" return from the IFERROR to B2:
=IFERROR(DATEVALUE(LEFT(RIGHT(B2,(LEN(B2)-(FIND("-",B2)-3))),11)),B2)
If that is not sufficient you can do an IF to test if date:
=IF(ISNUMBER(B2),B2,IFERROR(DATEVALUE(LEFT(RIGHT(B2,(LEN(B2)-(FIND("-",B2)-3))),11)),""))
This is a solution I came up with with appears to work for almost Any Date format provided the date is at the top of the cell. Note this was done for dates in cell H6 of my workbook.
The formula below can be entered below to extract the date from this cell amongst text.
=TEXT(IFERROR(LEFT(H6,SEARCH(CHAR(10),H6,1)-1),H6),"dd-mmm-yyyy")
This formula checks if the date is within 3 years and returns a true of false value. This can be used to conditionally Format Cells if the date once extracted is out of date.
=IF(ISBLANK(H6),FALSE,IFERROR(IF(DATEVALUE(TEXT(IFERROR(LEFT(H6,SEARCH(CHAR(10), H6, 1)-1),H6),"dd-mmm-yyyy"))<=TODAY()-(365*3),TRUE,FALSE),TRUE))
Works really well for me!
I have in a cell two numbers "=5+4" as a text. This is a result of another operation.
I took a part of another formula and concatenated it with "equal" symbol:
= "=" & RIGHT(FORMULATEXT(V8);LEN(FORMULATEXT(V8))-SEARCH("+"; FORMULATEXT(V8)))
I want to get the result of 5+4 in a cell- which means "9" ;)
I DO NOT WANT TO USE VBA code.
my initial problem was to extract all numbers except the first one from an equation and sum in another cell: A1: "=6+5+4". A2: "9". Maybe it can be solved without VBA?
You could try (assuming only addition):
Formula in B1:
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(MID(A1,2,LEN(A1)),"+","</s><s>")&"</s></t>","//s[position()>1]"))
In fact, if you don't want to use the 1st number we could also discard taking '=' into account:
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(A1,"+","</s><s>")&"</s></t>","//s[position()>1]"))
And since SUM() will ignore text in the final answer, we can now even further simplify this (thanks #JosWoolley):
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(A1,"+","</s><s>")&"</s></t>","//s"))
If you are always adding 2 numbers, then you can use this:
=VALUE(VALUE(MID(A1;2;SEARCH("+";A1)-2))+VALUE(MID(A1;SEARCH("+";A1)+1;9999)))
My column A is formatted as text, and all values follow same pattern: =Value1+Value2
So the formula extracts Value1 and Value2 as text with MID functions, based on the position of + symbol. Then Excel convert both values into numeric with VALUE function. Notice there are 3 values, the third one is to make sure the cell stays at standar format (in some versions of Excel, like mine 2007, when involving text formatted cells into formulas, the formulated cell autoformat itself to text format, making the formula to work just once).
As you can see in the image, it works perfectly but this is just for pattern =Value1+Value2. For different patters you'll need different formulas.
If you want to make a formula to work with all patterns, then indeed you need VBA.
I have a column of dates with this format (19960124) for instance, and I want to change it to this format (yyyy-MM-dd) on Excel.
I tried all the date formates in Excel, but it gives me #################..etc.
How can I fix this?
Sadly, just changing the format is not good enough.
If you use a Custom Format of:0000-00-00 you get:
But this is not a true date. You need a formula to convert it into a date.
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
Assuming your date string is in A2, then try this...
In B2
=DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2))
And you can then format the formula column with the desired date format.
You can use the Text function to change the date format in the formula itself, but then the date would be considered as a text string not a real date.
Sometimes this happens that Excel refuses the Cell Format command, to get rid from that better use Text command,
=Text(A1, "yyyy - mm-dd")
Drag if required.
ONE more simple example,,
=IF(A3="India",TEXT(C3*53.55,"Rs. #,##0.00"),IF(A3="U.K.",TEXT(C3*0.66,"£ #,##0.00"),IF(A3="Japan",TEXT(C3*99.5,"¥ #,##0.00"),C3)))
I have a VLOOKUP (actually an INDEX-MATCH) in an Excel cell.
This resolves ok but the resulting value has a leading zero, which Excel removes.
The standard solution (according to Google) is to format the cell as text, but if I do that the cell displays the formula instead of resolving it.
What format should I use?
This is an example of the formula (if it makes a difference):
=MID(INDEX('$save'!M23:M1021,MATCH(B70,'$save'!X23:X1021,0),1),2,99)
Thanks
For anyone else who is interested, this is how I solved it.
I needed to add the TEXT function into the formula:
=MID(TEXT(INDEX('$save'!M23:M1021,MATCH(B70,'$save'!X23:X1021,0),1),""),2,99)
How i can convert number 20020415 to date 15.04.2002. I am working in Microsoft Excel 2003?
Thanks!
If your numbers are always in the same format (i.e. yyyymmdd) then use Excel's Date function to convert your number to a date:
For example, assuming date 20020415 is in cell A1, then in cell B1 use:
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
This will make sure your number is of a date format which will make it easier to use in the future if you want to treat it like a date.
Then, using Format > Cells, select 'Date' and select the appropriate formatting option (in your case 15.04.2002).
As an aside, you can access the 'Format Cells' dialog box using the shortcut keys CTRL+1. I find this a highly useful shortcut to know.
If A1 contains a number instead of text, you can use this:
=DATE(INT(A1/10000),INT((A1-10000*INT(A1/10000))/100),A1-(100*INT(A1/100)))
This can then be formatted using Excel formatting options.
Let cell A1 contains the text 20020415.
=CONCATENATE(RIGHT(A1, 2), ".", MID(A1,5,2), ".", LEFT(A1, 4))
will produce 15.04.2002.
Afterward, if you want to store the value and not the formula you can copy and paste the value only.
Note: this method still keeps the date as text.