DF_DATE_FORMAT
The date format that is in use by DataFlex.
Level
Global
Supported by
All Drivers
Type
Numeric, temporary
Access
Read / Write
Values
DF_DATE_USADF_DATE_EUROPEANDF_DATE_MILITARY
Driver Configuration Keyword
None
Remarks
Dates, when presented as strings, can be of three different formats. The DF_DATE_FORMAT attribute indicates the format in use:
- The
DF_DATE_USAdate format is the month number followed by the day number followed by the year number (mm/dd/yyyy). - The
DF_DATE_EUROPEANdate format is the day number followed by the month number followed by the year number (dd/mm/yyyy). - The
DF_DATE_MILITARYformat is the year number followed by the month number followed by the day number (yyyy/mm/dd).
The year number can be either a two- or four-digit number. The numeric components of the date are separated by a character that is set with the DF_DATE_SEPARATOR attribute.
By default, the DF_DATE_FORMAT will conform to the regional settings on the machine. Windows visual controls also use the regional settings. If the DF_DATE_FORMAT does not conform to the regional settings, errors will occur when using certain Windows controls. For this reason, you should only set this attribute on a temporary basis or in programs that have no user interface.
Temporarily changing the date format is often used to output dates in a required format. Some applications need to output information for additional processing by other, possibly third-party, applications. If the additional processing requires dates in a certain format, the DataFlex application should change the current date format to the required one, output the data, and reset the current date format to its original value.
Example: ShowFormats
Procedure ShowFormats
Integer iDateFormat
String sDateFormat
Integer iDateSep
Integer iDecimalSep
Integer iThousandSep
Get_Attribute DF_DATE_FORMAT To iDateFormat
Get_Attribute DF_DATE_SEPARATOR To iDateSep
Get_Attribute DF_DECIMAL_SEPARATOR To iDecimalSep
Get_Attribute DF_THOUSANDS_SEPARATOR To iThousandSep
If (iDateFormat = DF_DATE_USA) Move "USA" To sDateFormat
Else If (iDateFormat = DF_DATE_EUROPEAN) Move "European" To sDateFormat
Else If (iDateFormat = DF_DATE_MILITARY) Move "Military" To sDateFormat
Else Move "Unknown" To sDateFormat
Send Info_Box ("Formats:\nDate:" * sDateFormat + ;
"\nDate separator:" * Character(iDateSep) + ;
"\nDecimal separator:" * Character(iDecimalSep) + ;
"\nThousand separator:" * Character(iThousandSep))
End_Procedure
This example obtains the date and number format in use by DataFlex and then pops up a message box that displays a message showing which format is in use.
Example: OutputRecords
Procedure OutputRecords Integer iChannel String sPathToFile
Integer iOrgDateFmt
Integer iOrgDateSep
Get_Attribute DF_DATE_FORMAT To iOrgDateFmt
Get_Attribute DF_DATE_SEPARATOR To iOrgDateSep
Set_Attribute DF_DATE_FORMAT To DF_DATE_MILITARY
Set_Attribute DF_DATE_SEPARATOR To (Ascii('-'))
Direct_Output Channel iChannel sPathToFile
Clear OrderHea
Repeat
Find Gt Orderhea By 1
If (Found) Writeln Channel iChannel OrderHea.Order_Number "," Orderhea.Order_date
Until (Not(Found))
Close_Output Channel iChannel
Set_Attribute DF_DATE_FORMAT To iOrgDateFmt
Set_Attribute DF_DATE_SEPARATOR To iOrgDateSep
End_Procedure
This example temporarily changes the date format in use to output the contents of a table to an ASCII disk file. The date column is written in military format.