PDA

View Full Version : [SOLVED] IF statements using DATE values



RHurlburt
03-26-2005, 02:13 PM
I have a need for "IF" using the values in cells which are in date format. These date values are the result of formulae OR values in another workbook. I have the need to write something like:

=IF((Date1=Date2),T (a formula here),F (a different formula here)).

The values are in, as an example, T12 and V9. The format of the "visible" cells are "mmm-yy". (Many cells will end up being used with this formula)

As a starter, I looked at


=IF(TEXT(A1,"ddd")="Sat","Yes","No")

But that is for text and I am using date. And, the above is incomplete for what I want to do.

And, I can't use VBA at to do this particular .

Will I need some sort of "COMPARE" and then the IF?

Thanks!!

I tried:
=IF(EXACT(T12,V9),"T","F")
and received "F", even tho the cells display the same "Jun=06".

SOLVED.
I changed the format to General and noticed that the number was different:
38533 to 38532. June 30, 2006 vs June 29, 2006. I change my formula to calculate the June 30 date, and now my IF formula works perfectly.

"What a difference a day makes." <g>

Richard

mdmackillop
03-26-2005, 02:56 PM
Is there a reason you need to use the text value?

=IF(WEEKDAY(A1)=7,"Yes","No") will return the same result.

RHurlburt
03-26-2005, 04:11 PM
No, no reason at all. That example was one I grabbed to try to explain my dilema. I like your solution better, so there it goes into my folio ... shades of copyrights!! Interesting thread over there.

At any rate my problem was that the "base number" was off by one but displaying the month and year appropriately. Once I changed the format to general, I saw the numeric difference and changed my formula accordingly.

Just as an FYI, I had the formula using "(date)+90", and had to change it to "(date)+91" to get the month to end properly (Was June 29, 2006, needed June 30, 2006).

Confusing isn't it (my explanation).

I could then fall back to my "=IF(T12=V9, etc., etc.)" solution ... the dates were now equal.

Thanks a bunch for responding.

mdmackillop
03-26-2005, 04:33 PM
Hi,

Check the EOMonth function in the help file. You need to add the Analysis Toolpack Add-In for it to work.

RHurlburt
03-26-2005, 04:35 PM
Thank you.
Richard