Professional edition.
Operational Range for Data: When using strict date formats, {^0001-01-01}, January 1st, 1 A.D. to {^9999-12-31}, December 31st, 9999 A.D.
Can applications be built with this tool that adhere to the Microsoft Year 2000 Compliance Statement?
Yes, if during design time 4-digit years are specified in date constants, and at run time one of the following actions is taken:
- 4-digit years are used for data entry.
- Set Century To Rollover is used to specify the year equal to and above which a 2-digit year is in the 1900s and below which a 2-digit year is in the 2000s.
How the product runtime handles dates:
Dates in variables and calculations are represented as 8-byte numeric values representing the number of days since some fixed date. In tables, date types use 8 bytes per field per record on disk and are stored internally as numeric values. This size is not affected by the settings of SET CENTURY or input masks on textboxes for data entry. This provides for full, unambiguous dates being stored independent of application logic.
Clock Dependencies
The system clock is used to determine DATE(), TIME(), SECONDS() and DATETIME(). YEAR(), MONTH(), DAY(), DOW(), CDOW(), HOUR(), MINUTE(), and SECS() are not dependent upon the system clock but use the date value argument.
Two-digit shortcut handling:
Handling of dates with 2-digit years is determined by the use of Set Century ToàRollover. The developer can specify the century to which dates with 2-digit years belong. Values equal to and above the rollover value are considered to be in the specified century; values below the rollover date are considered to be in the following century. The default value for the rollover year is the last 2 digits of the current year plus 50 years - if the current year is 1999, then the rollover year becomes 2049 (1999 + 50).
Recommended practices to develop year 2000 compliant applications:
Use Set Century On
Set Century On causes Visual FoxPro to display dates with 4-digit years during data entry and display. The product default is Set Century Off. In the Off setting, it can be impossible to enter 4-digit dates and 2-digit dates are interpreted based on the setting of Set Century To Rollover.
Note: Regardless of how Century is set, users can enter dates with 2-digit years. These dates will be interpreted based on the setting of Set Century To Rollover.
Use Set Century To Rollover
Handling of dates with 2-digit years is determined by the use of Set Century ToàRollover. The developer can specify the century to which dates with 2-digit years belong. Values equal to and above the rollover value are considered to be in the specified century; values below the rollover date are considered to be in the following century. The default value for the rollover year is the last 2 digits of the current year plus 50 years - if the current year is 1999, then the rollover year becomes 2049 (1999 + 50).
Use the Century Property of Controls on Forms
If the Century Property of a control is set to 1 û On, the century portion of a date is displayed in the control. This property overrides the current setting of SET CENTURY. The default for the Century property in Visual FoxPro 6.0 is 1 û On.
Use the Strict Date Format
Normally, Date and DateTime constants or expressions are interpreted based on the current settings of SET DATE and SET CENTURY at the time the constants or expressions are compiled or evaluated. This means that many date constants are ambiguous since they might evaluate to different values depending upon when they were compiled and what date settings were in effect at compilation time.
To avoid ambiguity, use the strict date format. A strict date evaluates to the same Date or DateTime value regardless of date settings. The strict date format is: ^yyyy-mm-dd[,][hh[:mm[:ss]][a|p]]
Use Strict Date Checking
Setting STRICTDATE to 1 requires that Date and DateTime constants be in the strict date format. Date or DateTime constants that are not in the strict format or evaluate to an invalid value generate an error, either during compilation, at run time, or during an interactive Visual FoxPro session. 1 is the default setting for an interactive Visual FoxPro session. Setting STRICTDATE to 0 means that strict date format checking is off. 0 is the default setting for the Visual FoxPro run time and ODBC driver.
The General tab of the Options dialog box now includes a Year 2000 Compliance drop-down list box, which specifies the setting of SET STRICTDATE. Like other Options dialog items, the value is set for the current Visual FoxPro session, and choosing Set As Default saves the setting to the Windows registry for the next Visual FoxPro session.
It Is Recommended that CTOD( ) and CTOT( ) Not Be Used
If the application has SET CENTURY OFF, search the code for CTOD( ) and CTOT( ) commands and change them to DATE( ) or DATETIME( ) functions. Also, consider using DTOS( ) instead of DTOC( ) if converting from a date to character expression. The DTOS( ) function will return a 4-digit year regardless of SET CENTURY setting.
DATE( ) and DATETIME( ) Functions
The DATE( ) and DATETIME( ) functions now support optional numeric arguments that lets users create year 2000 compliant Date or DateTime values. The enhancements to these functions now provide a preferable method for creating Date and DateTime values; it is no longer necessary to use character manipulation functions to create Date and DateTime values.
FDATE( ) Function
The FDATE( ) function now supports an optional argument that lets users determine the time when a file was last modified without using character manipulation functions. For example, in previous versions of Visual FoxPro, it was necessary to write code such as the following to determine when the Visual FoxPro resource file was last modified:
tLastModified = CTOT(DTOC(FDATE(æFoxuser.dbfÆ)) + æ Æ + FTIME(æFoxuser.dbfÆ)
This code can now be replaced with the following:
tLastModified = FDATE(æFoxuser.dbfÆ, 1)
Other Issues to Consider
The Visual FoxPro 5.0 documentation states that issuing SET CENTURY TO without additional arguments sets the century to the current century. This is only true in the 1900s, because the century is set to 19 regardless of the current century. In Visual FoxPro 5.0 the default rollover value is 0. In contrast, in Visual FoxPro 6.0, SET CENTURY TO sets the century to the current century. Additionally, the value of SET CENTURY TO in new data sessions is initialized to the current century.
In Visual FoxPro 6.0, the default ROLLOVER value for SET CENTURY has changed to the last 2 digits of the current year plus 50 years - if the current year is 1998, then nYear is 48, and the default rollover value becomes 2048 (1998 + 50).
In Visual FoxPro 5.0, the smallest date value that can be expressed is {^0100/1/1}, January 1, 100 A.D. This is because year values less than 100 were rounded up to the nearest century based on the setting of SET CENTURY. The smallest valid date in Visual FoxPro 6.0 is {^0001-01-01}, January 1, 1 A.D. The largest valid date in Visual FoxPro 6.0 is {^9999-12-31}, December 31, 9999 A.D.
In Visual FoxPro 6.0, LUPDATE( ) now queries the Windows operating system to determine the date a table was last updated, allowing users to determine the century in which the table was updated. Still, however, the table header just stores the last 2 digits of the year it was last updated. This is done to ensure backward compatibility with other versions of FoxPro.