Click or drag to resize

SetDateFormat Function

Change the setting that determines the X# date format.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.2a
Syntax
 FUNCTION SetDateFormat(
	cNewSetting AS STRING
) AS STRING
View Source

Parameters

cNewSetting
Type: String
The new date format to be set, in a string of 37 characters or less.  The date format can be specified in a number of ways, but must contain one or more occurrences of the letters D, M, and Y (respectively).  For example:

Return Value

Type: String
TRUE if the argument is the same as the current setting; otherwise, FALSE.
Remarks
SetDateFormat() analyzes the new format specified by <cNewSetting> and determines both the proper placement and number of digits for the day, month, and year based on the D, M, and Y letters it finds. SetDateFormat() is a global setting that affects the behavior of dates throughout a program, allowing you to control date formatting in a way that facilitates porting applications to foreign countries.
Examples
This example uses SetDateFormat() to set a date format:
X#
FUNCTION T()
        LOCAL x AS STRING
        ? GetDateFormat()
        x:="DD-ABC-YYYY-123-MM"
        ? x
        SetDateFormat(x)
        ? GetDateFormat()
        ? TODAY()
        ? 00.00.00
        ? CTOD("31.1992.12")
        ? CTOD(NULL_STRING)
        SetCentury(FALSE)
        ? GetDateFormat()
This example illustrates how SetDateFormat() can ignore or include the century digits:
X#
SetDateFormat("Year: YY, month: MM, day: DD")
? SetCentury()                                                        // FALSE
SetDateFormat("DD. day of month MM in the Year YYYY")
? SetCentury()                                                        // TRUE
See Also