| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Converts a Date value to a character string in SET DATE format.
DtoC( <dDate>) --> cDateString
The return value is a character string formatted in the current SET DATE format.
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.
| 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 |
// 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
http://www.xHarbour.com