Microsoft KB Archive/214623

= PRB: Some SET CENTURY Options May Not Prevent Four Digit Dates =

Article ID: 214623

Article Last Modified on 8/9/2006

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q214623



SYMPTOMS
The dates in text boxes might display the year with four digits even after issuing SET CENTURY OFF in any version of Visual FoxPro or issuing a SET CENTURY TO ROLLOVER  in Visual FoxPro 5.0 or 6.0.



STATUS
This behavior is by design.



MORE INFORMATION
Beginning in Visual FoxPro 3.0, date values began appearing in four digits to prevent any confusion regarding the correct century. This feature is called Auto-Century. The Auto-Century feature ensures that any date written to a text box has the century the user intended.

Auto-Century operates differently in various versions of Visual FoxPro. In Visual FoxPro 3.0x and later with SET CENTURY OFF in effect, the text box displays four digit dates whenever the year is greater than 1999. Visual FoxPro 5.0x and 6.0 display a four digit date even after issuing a SET CENTURY TO ROLLOVER when the century portion of the date exceeds the SET CENTURY TO value. Auto-Century ignores the ROLLOVER value.

Steps to Reproduce Behavior
 In Visual FoxPro 3.0b, 5.0x, or 6.0, create a form with a text box called Text1.  Add a command button, and set the Caption property to 1959. In the Click event of the object, add the following code: ThisForm.Text1.Value={01/01/1959}   Add a second command button and set the Caption property to 2029. In the Click event of the object, add the following code: ThisForm.Text1.Value={01/01/2029}  Save the form and call it Zdatetest. Activate the Command window and issue a SET CENTURY OFF command. Run the form. Click the buttons and observe the textbox.</li></ol>

The date appears in the text box in four digit form even though SET CENTURY is set off.

NOTE: In Visual FoxPro 6.0, the Century property can be used to force a two-digit date by setting it to 0 - Off.

To demonstrate how Auto-Century interacts with SET CENTURY TO ROLLOVER command, which is available in versions of Visual FoxPro after 3.0b, perform the following steps:


 * 1) Perform steps 1 through 4 listed above.
 * 2) Activate the Command window and issue a SET CENTURY TO 19 ROLLOVER 70.
 * 3) Run the form.

In Visual FoxPro 5.x, the text box displays four digits whenever the century portion of the year is greater than the SET CENTURY TO value. In Visual FoxPro 6.0, the textbox displays four year digits for both dates. Visual FoxPro ignores the ROLLOVER value.

Running the example in Visual FoxPro 5.0x, the textbox reports the first date {01/01/1959} as 01/01/59 because the century is equal to 19. However, 01/01/2029 appears in four digit form since the century of this date is equal to 20 while SET CENTURY is set to 19. Note that the ROLLOVER value is ignored.

Running the same example in Visual FoxPro 6.0 displays 01/01/1959 and 01/01/2029 respectively.

<div class="references_section">