PRB: DTOC() Output Erroneous If Invalid Date Is Used

Last reviewed: June 27, 1995
Article ID: Q96347
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a

SYMPTOMS

The DTOC() function does not report on the validity of the date being processed. An incorrect entry of a date being used for comparison can result in unexplainable, erroneous results.

CAUSE

The DTOC() function processes date type information into a character string. An invalid date results in a blank date without any warning; for example:

   STORE DTOC({06/30/92}) TO badate.

   ? badate && Note '06/30/92' will be displayed

   STORE DTOC({06/31/92}) TO badate

   ? badate && Note ' / / ' will be displayed

Although this example illustrates that FoxPro knows June does not have 31 days, FoxPro returns blanks instead of giving a warning message. This can cause unexpected results in selecting records when DTOC() results are being used for comparison.

RESOLUTION

Whenever a report, query, or other output results in ALL records being output and a DTOC() function was being used for comparison, check the validity of the date in the DTOC() function by also checking for blank dates.


Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a every day month
KBCategory: kbprg kbprb
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.