xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DtoC()

Converts a Date value to a character string in SET DATE format.

Syntax

DtoC( <dDate>)  --> cDateString

Arguments

<dDate>
The parameter must be a value of data type Date.

Return

The return value is a character string formatted in the current SET DATE format.

Description

The function converts a Date value to a character string. The string is formatted according to the current SET DATE format. The default date format is "MM/DD/YY".

Important:  use DtoC() and its counterpart CtoD() with extreme care. The result of both functions depends on the current SET DATE and SET EPOCH format.

Info

See also:CtoD(), Date(), DtoS(), SET CENTURY, SET DATE, SET EPOCH, StoD(), Transform(), TtoC()
Category: Conversion functions , Date and time
Source:rtl\dateshb.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example creates a date format independent Date value and
// outlines a common problem with date to string conversions. The
// last CtoD() call yields a date in October instead of January.

   PROCEDURE Main
      LOCAL dDate := StoD( "20060110" ) //  10th of January, 2006
      LOCAL cDate
                                        // use default date format
      ? cDate := DtoC( dDate )          // result: 01/10/06

      SET DATE ITALIAN                  // select Italian date format

      ? DtoC( dDate )                   // result: 10-01-06

      SET CENTURY ON
      SET EPOCH TO 2000

      ? DtoC( dDate )                   // result: 10-01-2006

                                        // CAUTION: date format mismatch
      ? CtoD( cDate )                   // result: 01-10-2006
   RETURN

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