Archive of Mr Excel Message Board


Back to Dates in Excel archive index
Back to archive home

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


Re: Using a date in a IF-statement

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


Re: Using a date in a IF-statement

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 :-)

Re: Using a date in a IF-statement

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


This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.