Microsoft KB Archive/40159

-

{|
 * width="100%"|

The information in this article applies to:
 * Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 5.0
 * Microsoft Excel for OS/2, versions 2.2, 3.0
 * Microsoft Excel for the Macintosh, versions 2.2, 3.0, 4.0, 5.0

SUMMARY
You must make sure that the serial numbers match exactly when comparing two dates in Microsoft Excel. If you enter the date 8/9/88, Excel will interpret this as the serial value 32364.0000000000, or 8/9/88 12:00:00. When the date becomes 8/9/88, the following function still returns FALSE, even though the date is now 8/9/88:

=IF(NOW=DATEVALUE(&quot;8/9/88&quot;),TRUE,FALSE) The function will return TRUE only when the date is 8/9/88 12:00:00.

WORKAROUND
Use the TRUNC function whenever comparing two dates in which the time is insignificant. The formula is as follows:

=IF(TRUNC(NOW)=DATEVALUE(&quot;8/9/88&quot;),TRUE,FALSE) In Microsoft Excel 3.0 and later, the TODAY function may be used in place of TRUNC(NOW). The TODAY function returns only the date portion of the serial value for the current date so the formula will evaluate correctly. The formula is as follows: =IF(TODAY=DATEVALUE(&quot;8/9/88&quot;),TRUE,FALSE)
 * }

-

Last reviewed: March 26, 1998

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.