Set Date, DateFormat, Set Century, Century, Set Mark To, DateMark
These three SET commands and their equivalent local properties for text boxes combine to change the way that dates are displayed in your application. These settings are for display only, and make no difference in how the date is actually stored in the machine. (FoxPro always stores the full four-digit year; see "DBF, FPT, CDX, DBC—Hike!" for a description of the actual disk storage.)Each of the SET commands may also be performed in the Tools | Options dialog, on the Regional tab. Within the development product, if saved as the default, they are stored in the Registry. They may be overridden at startup with commands in the configuration file CONFIG.FPW or programmatically at any time. Each of these SET commands is scoped to a private data session. SET SYSFORMATS ON causes FoxPro to ignore their settings and use the Control Panel's Regional settings instead.As with most SET commands, we feel that you should set them and forget them—leave them the same for the entire application if at all possible. Use the local equivalents to get local exceptional behavior. If possible, consider using the user's preferences for date display, as set in the Control Panel Regional applet, using SET SYSFORMATS. Check out that topic for the care you'll need to take with that command.
Usage |
SET CENTURY ON | OFF | TO [ nCentury [ ROLLOVER nRollOver ] ] cOnOrOff = SET( "CENTURY" ) nCentury = SET( "CENTURY", 1 ) nYear = SET( "CENTURY", 2 ) nSystemRolloverYear = SET( "CENTURY", 3) TextBox.Century = nCenturySetting |
Parameter |
Value |
Meaning |
nCentury |
1 to 99 |
The century to stick in front of two-digit years when converting to dates using the {} delimiters or the CTOD() and CTOT() functions. |
Omitted |
nCentury defaults to 19 (even if the system date is 2001!) and nRollOver defaults to 0. |
|
nRollOver |
0 to 99 |
Assume when converting two-digit years that years less than nRollOver occur in nCentury plus one. |
Omitted |
Rollover behavior defaults to setting of zero. |
|
nCenturySetting |
0 |
Century is OFF for this text box. |
1 |
Century is ON for this text box. |
|
2 |
Default—display or hide century depending on the global (if no private datasession) or form-wide setting of SET CENTURY. |
Example |
SET CENTURY ON SET CENTURY TO 19 ROLLOVER 50 ? {12/7/41} && displays 12/07/2041 ? {12/7/63} && displays 12/07/1963 ? SET("CENTURY", 3) && With default settings, displays 2029 |
Usage |
SET DATE [TO] cDateFormat cDateFormat = SET( "DATE" ) nOrder = SET( "DATE", 1 ) TextBox.DateFormat = nFormat |
Parameter |
Value |
Meaning |
cDateFormat |
AMERICAN or MDY |
Month-day-year order. MARK is a slash if not overridden by SET MARK. |
ANSI |
Year-month-day order with the period as the default MARK. |
|
BRITISH, FRENCH or DMY |
Day-month-year order with the slash as the default MARK. |
|
GERMAN |
Day-month-year with the period as the default MARK. |
|
ITALIAN |
Day-month-year with the dash as the default MARK. |
|
JAPAN or TAIWAN or YMD |
Year-month-day with slashes as the default MARK. |
|
LONG or SHORT |
The Date format is in accordance with the long or short settings in the Windows Control Panel Regional applet. These settings override the settingsof HOURS, CENTURY, MARK and SECONDS, whether made before or after SET DATE. |
|
USA |
Month-day-year with the dash as the default MARK. |
|
nOrder |
0 |
MDY |
1 |
DMY |
|
2 |
YMD |
|
nFormat |
Numeric |
The format to use, based on this list: |
txtMyDate.DateFormat = C_GERMANDATEIf you have to know the position of the various components within the date, Microsoft introduced the ,1 argument to SET("DATE") in VFP 5.
Usage |
SET MARK TO [ cExpression ] cMark = SET( "MARK" ) TextBox.DateMark = cMark |
Help seems to indicate that the delimiter is changed, from dashes to slashes to dots, using SET DATE. This is only the case if a MARK has not already been SET, either explicitly or by FoxPro reading a set of defaults from the Registration Database on startup. To be certain you change both the order and the mark of the date display, you must explicitly issue a separate SET MARK TO command with no argument (see below). |
Help claims that omitting cExpression resets the mark to a slash. It doesn't—it resets the mark character to the default for the current setting of DATE. If SET("DATE") = "GERMAN" and you issue the command SET MARK TO, the mark is now a dot. |
Example |
SET MARK TO "#" SET DATE TO ANSI ? DATE() && Returns date with # delimiters SET MARK TO ? DATE() && Returns date with ANSI "." delimiter |
See Also |
#Include, Configuration Files, Date(), Day(), DMY(), DoW(), GoMonth(), MDY(), Month(), Registration Database, Set Hours, Set Mark Of, Set Seconds, Set SysFormats, StrictDateEntry, Year() |