BUG: Date in Text Box Displays Year with Four Digits

Last reviewed: March 20, 1998
Article ID: Q174426
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a

SYMPTOMS

If your system year is 2000 or higher and you display the DATE() in a text box, the year will display with four digits regardless of the SET CENTURY setting. This behavior also appears with @GET commands.

RESOLUTION

To work around the problem, wrap the DATE() function with DTOC() function. This will correctly display the date in a text box, for example:

   Thisform.Text1.Value = DTOC(Date())

You may also want to setup a input mask so a user can enter a date in the text box.

   Thisform.Text1.Inputmask = '99/99/99'

NOTE: This will be a character data type. Therefore, use the CTOD() function before writing the date back to a table and also check the century of the year.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Set your system date to the year 2001.

  2. In the Command window issue the command SET CENTURY OFF.

  3. Add a text box to a form.

  4. Set the Value property of the text box to DATE().

  5. Run the form. The year appears with four digits instead of two.


Additional query words: kby2k Year 2000

(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by David
Botzenhart, Microsoft Corporation

Keywords : FxprgGeneral vfoxwin
Version : WINDOWS:3.0,3.0b,5.0,5.0a
Platform : WINDOWS
Issue type : kbbug


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: March 20, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.