PRB: SET CENTURY ROLLOVER Ignores Setting of SET CENTURY OFF (167186)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
This article was previously published under Q167186 SYMPTOMS
When using the ROLLOVER parameter of SET CENTURY, the SET CENTURY OFF
setting is ignored. This results in a date display consisting of either two
digits or four digits for the year portion of the date.
RESOLUTION
The reason for the display of the year in either a two- or four-digit format is to differentiate which century the date belongs to.
It is possible to create a custom display format, which presents the date
in the MM/DD/YY format along with another field to display which century.
The following program demonstrates a sample method to do this.
Step-by-Step Procedures- Save the following code as Daterev.prg:
*** Begin code ***
ON KEY LABEL f2 CLEAR EVENTS
ON KEY LABEL f3 DO refresh
SET CENTURY to 19 ROLLOVER 60
SET CENTURY off
dateform=CREATEOBJECT('form')
WITH dateform
.width=300
.height=65
.ADDOBJECT('text1','textbox')
WITH .text1
.format='K'
.inputmask='99/99/99'
.left=1
.top=10
.width=60
.value=DTOC(date())
.visible=.t.
ENDWITH && text1
.ADDOBJECT('label1','label')
WITH .label1
.top=50
.left=90
.width=120
.fontbold=.t.
.caption="Press <F2> to exit form"
.visible=.t.
ENDWITH && label1
.ADDOBJECT('label2','label')
WITH .label2
.caption="Year of date shown is "+ ;
ALLTRIM(STR(YEAR(CTOD(dateform.text1.value))))
.top=32
.left=10
.width=160
.fontbold=.t.
.visible=.t.
ENDWITH && label2
.ADDOBJECT('label3','label')
WITH .label3
.caption='Press <f3> to refresh after entering new date'
.top=10
.left=65
.width=250
.fontbold=.t.
.visible=.t.
ENDWITH && label3
.show
ENDWITH && dateform
READ EVENTS
ON KEY LABEL f2
ON KEY LABEL f3
PROCEDURE refresh
dateform.label2.caption="Year of date shown is: "+ ;
ALLTRIM(STR(YEAR(CTOD(dateform.text1.value))))
dateform.refresh
RETURN
*** End code ***
- Run the program, and note that the four-digit display of the date shown is shown below the text box.
- Enter a valid date for the 21st century, such as "02/12/55."
- Press the F3 key to refresh the display, and note that in the line below the text box, the year is shown as "2055."
STATUS
This behavior is by design.
REFERENCES
For more information about SET CENTURY, search for CENTURY in the Visual
FoxPro Help file.
Modification Type: | Minor | Last Reviewed: | 2/16/2005 |
---|
Keywords: | kbprb kbProgramming KB167186 |
---|
|