xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

TtoS()

Converts a Date value to a character string in YYYYMMDDhhmmss.ccc format.

Syntax

TtoS( <dDateTime>)  --> cYYYYMMDDhhmmss.ccc

Arguments

<dDateTime>
The parameter must be a value of data type Date or DateTime.

Return

The return value is a character string of 18 bytes in lenth formatted as "YYYYMMDDhhmmss.ccc".

Description

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.

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe