compare date in cell with today() for conditional formatting - excel

I am trying to create conditional formatting where I compare dates in the cells of a column with today(). However, when I check with evaluate formula, today() gives a short date (44231) and my cells are formatted as 24/08/2021
The result of =B2<today() thus results in false even though it is true. How can I solve this?

You need to convert your string into a date value, which can be done using the DATEVALUE() function, explained here. Be very careful working with that function, because it's related to your regional settings: does "01/02/2021" mean the first of February or the second of January?

Related

Extracting Date From Cells using excel formulas

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!

How to check if a cell is the 17th of any month

I have a column of dates (daily) and I want an IF statement that will check if the corresponding cell is the 17th of any month.
I'm happy with the syntax of if statements but am unsure how I should be using wildcards here. 'x'below can be any numerical value.
The cell in question looks like - 17/07/2019.
= IF( cell = 17/**/****,x,0)
Excel gets confused and tries to show me how to do maths without a formula.
If you already know that the date is not a text value you can use a simple formula like:
=IF(DAY(A1)=17,”x”,0)
The only issue is that your dates may be genuine Excel dates or text values. With data in A1, in another cell enter:
=IF(ISNUMBER(A1),IF(DAY(A1)=17,"X",0),IF(LEFT(A1,2)="17","X",0))

excel conditional formatting validate date

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.

Excel conditional formatting with blanks and Today()

I am trying to get a cell to highlight, given 2 criteria. The cell must be blank, and today's date must be after a predetermined date that is listed in another cell(R8C3). I'm also using R1C1 notation, but understand A1 notation as well.
The part I don't understand is that each criteria works independently, but when I use the AND function it no longer works. The relative references are used since this formatting will span multiple columns.
=ISBLANK(RC) evaluates to true and highlights correctly.
=TODAY()>=INDIRECT(ADDRESS(ROW(R8C3),COLUMN(RC))) evaluates to true and highlights appropriately.
=AND(ISBLANK(RC),TODAY()>=INDIRECT(ADDRESS(ROW(R8C3),COLUMN(RC)))) Does not highlight.
A slightly modified version pasted in a cell ( to check that the formula works) evaluates appropriately to TRUE or FALSE.
=AND(ISBLANK(RC3),TODAY()>=INDIRECT(ADDRESS(ROW(R8C3),COLUMN(RC3))))
I'm using Excel 2010 (version 14) on a Windows 7 device.
Try this:
=(J$1>K$1)*(ISBLANK(A1))
where J1 has the current date and K1 the threshold date.
The indirect statement seems unnecessarily convoluted... why not just use a mixed reference?
=AND(ISBLANK(RC), TODAY()>=R8C)

Excel 2010 Conditional Formatting Issue using VALUE

I am trying to conditionally format a range of cells based on the value of the right two digits. I'm using the following formula and it isn't working:
=VALUE(RIGHT($N2,2)) > 80
I'm trying to avoid splitting the column into two separate columns (it's a blood pressure reading, the figures belong together).
Your formula evaluates to TRUE and FALSE okay. When you say it isn't working I assume it's not doing anything at all, rather than giving wrong results. Have you remembered to set the format, as well as entering the condition!? Remember it will only format if it evaluates to TRUE... If these are correct, have you entered the formula as the condition and used the 'Use formula to determine which cells to format...Format values where this formula is true' rule type?

Resources