Using a date in a IF-statement


Posted by Michael on September 19, 2001 12:02 AM

If cell A1="08:00:00", the formula :
=IF(A1>"05:00:00";1;0)
returns 0 !!!

So, what am I doing wrong ?
I've tried with different (time)formats in A1, but nothings helps.

with regards
Michael

Posted by Richard S on September 19, 2001 12:20 AM

Michael,

I'm pretty sure that by putting "05:00:00" in your formula, Excel isn't recognising it as a time, but as text. If you put "05:00:00" in cell B1 and change your formula to
=IF(A1>B1,1,0)
it will return 1.

Richard

Posted by Michael on September 19, 2001 12:31 AM

You're absolutely right Richard,
it works if I'm using a cell in my formula !
Thnx :-)



Posted by Aladin Akyurek on September 19, 2001 1:02 AM

Yep.
However, you might occasionally need to use a constant like 05:00:00 directly in the formula. In that case, to overcome the trouble Richard pointed out, you'd use e.g.,

=IF(A1>"05:00:00"+0;1;0)

Aladin