Compare dates with IF - excel

Three columns below, I'm attempting to use column C as a formula that checks against a hard coded date.
8/18/14 12/19/20 formula
In column C =IF(AND("10/7/15">=A1,"10/7/15"<=B1),"IN","OUT")
What I'm looking for is to tell if 10/7/15 is between 8/18/14 & 12/19/20 - I would expect that to come back with a value of IN but it doesn't.... hoping its something simple I'm missing

I think the problem is you're comparing a date (which translates to a number) to a text string. It's a crap-shoot as to what Excel will do in this case. If you compare a date to a date, I believe you will get the desired behavior:
=IF(AND(DATE(2015,10,7)>=A1,DATE(2015,10,7)<=B1),"IN","OUT")
The datevalue function should also work.

If you really have a date in A1, you can try:
=IF(AND(VALUE("2015-10-07")>=VALUE(A1),VALUE("2015-10-07")<=VALUE(B1)),"IN","OUT")

Related

Excel Date Countifs

I need to count all dates that are "less than" today to see which work is overdue. I understand that this can be done simply with
=countif(F:F,"<"&TODAY())
However, the dates in Column F are formatted like "12/05 - Evening" instead of just "12/05". Because of this, the formula is not picking up anything. Does anyone know how to change this code so that it counts any cell that contains dates prior to today, even if there is other text in the cell? I've tried playing around with these "**", but can't get it to work.. Thank You!
So based on my comment I would get the date by using left() with find() like so:
LEFT(A1,FIND(" ",A1,1)-1)
Then format as short date and it behave as a date.
From comment:
Use a helper column and separate the date out then use the countif() on that column

LEN function in Excel not returning a numerical value

I'm having a strange issue here with Excel. I'm working with a custom datetime format in one column...
9/1/2017 12:02:01 AM
This is cell C2. However, using LEN on this cell gives me this...
1900-01-15 00:00:00
I've tried changing the format to General, or Text, and messing around with some custom datetimes, but it doesn't help. I will get the same answer. My goal here is to use this as an exercise and trim the date and time, putting them in separate columns. This spreadsheet was originally created using Google Sheets, not sure if that might explain it?
UPDATE: Ok, so about 1 minute after posting this I think I figured it out? I used LEN in the column to the left of column C, so B. I had been using column D. For some reason, column B returned the numerical value. Obviously I'm very new to Excel. I didn't think column placement mattered in this case. Why does it?
That's because you have formatted the result to be shown as a date.
Remember, dates are simply really large numbers. So, what has happened here is that you get the correct result from LEN(), but then you have formatted this result to be interpreted as a date.
The date seems to indicate the result was 15. In dates, this is 15 full days from 1900 January 1st.
So, you just have to change the format of that cell from a date, to be a number :)

Excel not properly comparing dates, despite same cell format

I have two date rows. Both are formatted as dates. When I do a logic test to see whether the two dates, excel is not recognizing them as the same.
Here is a screenshot of the cells:
This is to confirm that both cell rows are formatted as date:
This is to confirm that the equality check row is referencing the right cells:
I'm stumped. Does anyone have any idea what's going on here? Thanks
If you have confirmed that both are actually dates, and not text masquerading as dates, then time is most likely the issue. Note that time is represented via the decimal such that .5 equals noon.
Assuming you just want to know if the dates match independent of time you can use
INT(G4) = INT(G6)
If you want to compare just the dates use:
=Floor(G4,1) = Floor(G6,1)
Format can mask the real cell value. Format both cells as General, then you can see the difference.
If a cell stays a "date" when it is formatted as General, then the cell is most likely text, not a date.
When formatted as General, you can clearly see if the number has any decimals, i.e. time on top of the date.

IF statement to calculate days between dates if column contains date

I have two columns, Last Upload and Final Date. I have a formula to calculate the difference between today and the Last Upload using
=DATEDIF( [#[Last Upload]],TODAY(),"d")
However, sometimes the Last Upload column will be blank and in this case we would like to use the Final Date column instead.
Is there a way to combine and use the above statement when the column is not blank and the other when it is? I have been trying to nest it with an IF statement but struggling to do so.
You could use ISBLANK formula combined with IF formula.
=DATEDIF(IF(ISBLANK([#[Last Upload]]),[#[Final Date Upload]],[#[Last Upload]]),TODAY(),"d")
Alternative solution:
=DATEDIF(IF(LEN([#[Last Upload]]),[#[Last Upload]],[#[Final Date]]),TODAY(),"d")
LEN might be a little bit more error-proof than ISBLANK.

WEEKDAY Error With Excel

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.

Resources