SET CENTURY Command

Determines whether Microsoft Visual FoxPro displays the century portion of date expressions and how Visual FoxPro interprets dates that specify only 2 digit years.

SET CENTURY ON | OFF | TO [nCentury [ROLLOVER nYear]]

Parameters

  • ON
    Specifies a four-digit year in a format that includes 10 characters (including date delimiters).

    Note   To provide year 2000 compliance, it's recommended that you always set SET CENTURY to ON. For more information about year 2000 compliance, see Year 2000 Date Support.

  • OFF
    (Default) Specifies a two-digit year in a format that includes eight characters and assumes the twentieth century for date calculations.

  • TO nCentury
    A number from 1 to 99 that specifies the current century. When a date has a two digit year, nCentury determines in which century the year occurs. The ROLLOVER value determines whether the year is in nCentury or the century following nCentury.

  • ROLLOVER nYear
    A number from 0 to 99 that specifies the year equal to and above which is the current century and below which is the next century. The default value for nYear is the last two digits of the current year plus 50 years - if the current year is 1998, nYear is 48, the last two digits of 2048 (1998 + 50).

    Note that the rollover value only determines the century for a date entered without a century portion - an ambiguous date format that is not recommended.

    For example, if the current year is 1998 and nYear is the default (48), any date entered without a century portion and a year of 48 or greater is considered to be in the current century (the 20th century). Any date entered without a century portion but with a year before 48 is considered to be in the next century (the 21st century).

Remarks

Use SET CENTURY to specify how date variables and functions are displayed.

Issue SET CENTURY TO without any additional arguments to restore the default century to the current century and ROLLOVER to the default value of the current year plus 50 years. In Visual FoxPro 5.0, issuing SET CENTURY TO without any additional arguments sets the century to 19 and ROLLOVER to zero.

SET CENTURY is scoped to the current data session. New data sessions are initialized to the default values as specified above, ignoring the value of SET CENTURY for the current data session.

SET CENTURY TO ROLLOVER is available in Visual FoxPro 5.0 and later, and makes it possible for you to control the assumed year for dates used when the setting is SET CENTURY OFF. It also allows for a rollover value since many applications contain dates that span multiple centuries.

**Note   **SET CENTURY OFF always implies dates in the 20th century. However, the SET CENTURY TO syntax takes precedence over this setting. So, with Visual FoxPro 5.0 and later, the SET CENTURY ON/OFF setting only controls the number of digits displayed.

The value of SET CENTURY TO is scoped to the current data session.

In Visual FoxPro 5.0, issuing SET CENTURY TO without additional parameters sets the century to the current century –1 and rollover to zero if the two-digit year of the system date is less than 50. Century is set to the current century if the two-digit system date is greater than 50. For example, if the current year were 1998, nYear would be 48, the last two digits of 2048 (1998 + 50).

See Also

DATE( ) | SET DATASESSION | SET STRICTDATE | SET SYSFORMATS | YEAR( )