Click or drag to resize

TToC Function

X#
-- todo --
Converts a DateTime expression to a Character value with the specified format.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION TToC(
	tExpression,
	nParam
) AS STRING CLIPPER
Request Example View Source

Parameters

tExpression (Optional)
Type: Usual
Specifies a DateTime expression to convert into a character string.
If tExpression contains only a time, X# adds the default date of 12/30/1899 to tExpression. If tExpression contains only a date, X# adds a default time of 12:00:00 AM (if Set HOURS is 12) or 00:00:00 (if Set HOURS is 24) to tExpression to produce a valid DateTime value.
nParam (Optional)
Type: Usual
1 Returns tExpression as a character string in a format suitable for indexing. The character string returned has a 14-character format, yyyymmddhhmmss, that is not affected by the Set CENTURY, the Set HOURS, or Set SECONDS commands. For more information, see Set CENTURY, Set HOURS, and Set SECONDS. 2 Returns tExpression as a character string containing only the time portion of tExpression.
To control whether to include the seconds of the time portion in the character string, set the Set SECONDS and Set DATE commands. The Set HOURS command determines if AM or PM is appended to the time portion returned.
For more information, see Set DATE and Set HOURS.
Note Note
If Set DATE is set to LONG or SHORT, the format of the time setting in the Windows Control Panel determines the format of the character string.
3 Returns tExpression as a character string with the XML DateTime format. The character string returned has a 19-character yyyy-mm-ddThh:mm:ss format that is not affected by the settings of the Set CENTURY, Set HOURS, or Set SECONDS commands.

Return Value

Type: String
Character. TTOC( ) returns a DateTime expression as a character string.
Note Note
When passing the value 1 or 3 as the second parameter, the character string returned does not include the AM or PM designations to indicate times before or after noon, respectively. Instead, the string uses a 24-hour clock, also known as military time. For example, the time 18:30:00 is equivalent to 06:30:00 PM.
Remarks
If an invalid value is passed as the second parameter, TTOC( ) handles the invalid value as if it was a value of 1.
Examples
X#
1STORE DATETIME( ) TO gtDateTime
2? "gtDateTime has type: "+TYPE('gtDateTime')
3gtDateTime = TTOC(gtDateTime)
4? "gtDateTime is now type: "+TYPE('gtDateTime')
See Also