xHarbour Reference Documentation > Function Reference |
Converts a Date value to a character string in YYYYMMDDhhmmss.ccc format.
TtoS( <dDateTime>) --> cYYYYMMDDhhmmss.ccc
The return value is a character string of 18 bytes in lenth formatted as "YYYYMMDDhhmmss.ccc".
This function converts a Date value to a character string of 18 bytes length that is independent from the settings SET CENTURY, SET DATE, SET EPOCH, and SET TIME. Therefore, TtoS() and its counterpart StoT() are the recommended DateTime to Character string conversion functions, unless a DateTime value must be output in a country specific format.
When DateTime fields are combined with Character fields in an index expression, use TtoS() to concatenate the DateTime field with the Character field. This ensures that the Date field is sorted in chronological order.
See also: | DateTime(), DtoS(), SET CENTURY, SET DATE, SET EPOCH, StoD(), StoT(), TtoC() |
Category: | Conversion functions , Date and time , xHarbour extensions |
Source: | rtl\dateshb.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates TtoS() return values and outlines the effect of SET DATE and SET TIME for DateTime output. PROCEDURE Main LOCAL dDateTime := {ˆ 2007/04/26 16:31:24.789 } LOCAL cDateTime := TtoS( dDateTime ) ? dDateTime // result: 04/26/07 16:31:24.78 ? cDateTime // result: 20070426163124.789 SET DATE TO ITALIAN SET TIME FORMAT TO "hh:mm pm" ? dDateTime // result: 26-04-07 04:31 PM ? cDateTime // result: 20070426163124.789 ? cDateTime := TtoS( {ˆ 0/0/9 } ) // result: 000000.000 ? Len( cDateTime ) // result: 18 RETURN
http://www.xHarbour.com