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

ID: Q96347

The information in this article applies to:

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

Last Reviewed: June 27, 1995