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!
Related
I try to evaluate if a cell contains a valid date. If the content is not a valid date, the cell should be colored red. I want to do this without vb. On SO i got told, this is possible using only conditional formatting
Here is my try:
This doesn't work. I think the formular is fine, because i get no error message, but still no success.
Another try was to use Highlight Cells Rules and depending on a date occurring.
But here i can only use specific rules, like date is from this week, or this month, or past week. I can not say is a valid date or is a date between X and Y.
Any ideas how i can achieve my goal to set background-color of cells with invalid date-formats?
The issue comes from the fact that 31.12.1899 is not a reconized date in Excel.
An excel date is a number and it starts with 0 = 00.01.1900
So if you exchange your 31.12..1899 by 01.01.1900 your formula will work.
I need to convert this data dd/mmm - 31.mar (March) to this format 31/03 - dd/mm using excel formula
A bit of googling would have solved your issue here.
Select cell (or range of cells).
Right click with mouse
Format Cells
Custom
Change Type: dd/mmm to dd/mm
=text([CellWithDate],"dd/mm")
is the formula you want, I think.
#Valeria:
Can't be sure I understood your problem and/or the type of solution you're looking for.
I assume you have a date in , say, cell A1 and that cell is showing the date in "dd-mmm" format.
I also assume you want that date to be shown in another cell (different from A1) in "dd/mm" format BUT without previously setting that target cell format to "dd/mm".
In case I'm right, the formula you should put in the target cell shouldo look like:
=DAY(A1) & IF(MONTH(A1)<10;"/0";"/") & MONTH((A1))
This way, if cell A1 holds "31-aug", you're getting "31/08" wherever you put that formula.
The value Excel actually stores in the cell is just its date+time serial number (whatever you're seeing is a very different question). DAY() and MONTH() do work on that value to generate day of the month and month of the year after that serial number.
Hope this helps.
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.
I have a big sheet with a lot of formulas that have a dependency hierarchy between them. It starts with a cell with a date value. Then, cell x:y (and others), has formula depending on this date. Then cell w:z (and others) has a formula depending on cell x:y. And so on...
This main cell with a date value is filled using apache poi.
And now my problem: when I open the generated excel file, the date is there, but none of the formulas are calculated. They all have the error "A value used in the formula is of the wrong data type". It seems that when the formula try to evaluate it self the date isn't there yet.
Solutions:
1) If I click in the cell, and just press ENTER, the formula is correctly evaluated. But then I would have to do this for all cells.
2) I click in the date cell, copy it, and then paste it in the same place, and all formulas in the sheet are evaluated!
3) I could iterate in all cells in my application, evaluating each one with evaluateFormulaCell method from FormulaEvaluator class. But I have a lot of formulas and the performance of this is terrible.
Does someone have a solution for this?
Thanks!!
Your date value isnt recognized by the excel formulas as a date, what you could do is have another cell dat will first take the datevalue DATEVALUE() of the cell filled using Apache poi.
Then direct your first level formulas to that cell instead of the one filled using Apache poi
Because Excel don't calculale automatically, so just change this.
Excel 2010: File -> Options -> Formulas: Find Workbook calculation, and change to Automatically.
It worked for me.
To solve this, I changed all formulas in my template, to use instead of the regular formula sintax (=SUM(A:D)) the following sintax:
$[SUM(A:D)]
http://jxls.sourceforge.net/reference/formulas.html
I have dates in E2 and F2 cells of an excel.The dates are in MM/DD/YYYY fromat.I want to apply validation in such a manner that date in F2 must be greater then dates in E2 .
In case of failure we should display an error.
I am using Microsoft Office 2007.
Help would be appreciated.
You could use conditional formatting?
In your case the background of one of the dates could turn red if the date is too low compared to another.
Quick google:
http://www.homeandlearn.co.uk/excel2007/excel2007s6p2.html
Should be quite easy doing =IF(F2>E2;"SUCCESS";"ERROR")
You can omit the "SUCCESS" and you only display the error should it fail. This will work as long as the fields are actually formatted as a proper date.
Updated code:
=IF(AND(NUMBERBLANK(E2:F2)=0;F2<E2);"ERROR";"")
What this does is: Check if both cells are filled, if they are chech if E is smaller than F, and write ERROR if that is the case.
To do this for the entire column you need to replicate the formula. For existing dates, just double click the lower right knob in the cell the formula is, and it SHOULD replicate down till the end of the row (if the row is next to the date). Other than that, just pull the knob down as far as you need it.