PRB: SET("Century",1) Not Reporting Correct Century (190480)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q190480 SYMPTOMS
When the system clock of the computer is set to a year between 2000 and
2049, inclusive, and the SET CENTURY TO command is issued without any
additional arguments, the SET("Century",1) command returns 19 instead of
the expected 20.
RESOLUTION
The following code can be used as a workaround to the SET("Century",1)
command to return the century of the current date after a SET CENTURY TO
command has been issued:
ROUND(VAL(LEFT(ALLTRIM(STR(YEAR(DATE()))),2)),0)
Note that the SET("Century",1) command returns a numeric value. The ROUND()
and VAL() functions have been used in the preceding code to convert the
result of the LEFT() function to a numeric value with no decimal places.
These two functions can be eliminated if it is acceptable for the century
to be a character value.
Alternately, the following line of code can be used in place of the SET
CENTURY TO command to set the century to the current system clock century
and set the ROLLOVER values back to their defaults based on the system
clock:
SET CENTURY TO INT(YEAR(DATE())/100) ROLLOVER
MOD(YEAR(DATE())+50,100)
NOTE: Prior to using this code, please refer to the MORE INFORMATION section below to
make sure this is the behavior you want.
STATUS
This behavior is by design.
REFERENCES
Visual FoxPro Help, version 6.0; search on: "SET CENTURY"; topic: "Set
Century"
Visual FoxPro Help, version 6.0; search on: "SET()"; topic "SET()"
Modification Type: | Major | Last Reviewed: | 6/9/1999 |
---|
Keywords: | kbprb kbXBase KB190480 |
---|
|