excel conditional formatting validate date - excel

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.

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!

compare date in cell with today() for conditional formatting

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?

Compare times to a giving time in a cell

enter image description herei would like some help in trying to create a formula that compares a certain time in 1 cell to the Current time.in the end, i would like that cell to highlight a color if it is less then or equal to then the current time.
For example:
Cell A2 has a time of 14:00, highlight this cell Red if it is less then or equal too than the Current time.
You can just enter the formula =TEXT(NOW(),"H:MM") and then just do a conditional format as formula to say, cell C4<=A2 or what ever cell ref you have.
The NOW formula will return Todays date and the current time. The text formula allows you to remove the date, and display the time how you want it. "H:MM" will still return military time. If you want to go to standard use "H:MM AM/PM".
UPDATE: Try using the below format for the cell, and in the conditional formatting formula =($H$9<=(NOW()-TODAY()))
This should match up your formatting with the now function.
As for wanting to be able to just type in the time without having to hit the colon. The only way I know how to do that is cell format as Other and 00:00. However this is not a time format and it messes with the conditional formatting. So you will need to find a work around

Identify due date excluding weekends

I am using the following formula to change a cell's conditional formatting depending on how close to today's date the value is:
Cell Value is Between =TODAY()-5 and =TODAY()+5
This is working but I want to exclude weekends.
So if the date in the cell is 03/10/14 and today's date is 26/09/14 I would like to be able for my formula to identify that there are only 6 days and not 8 days which would include the weekend.
Please can someone tell me how what formula I would need to use to do this? I have tried to use the WORKDAY() function but can not seem to get it to work?
Assuming your dates are in ColumnA, please try this CF formula rule:
=AND(A1<=WORKDAY(TODAY(),5),A1>=WORKDAY(TODAY(),-5))

Compare dates of two cells in excel

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.

Resources