Function DtoC() Foundation

Converts a date value to a character string.

DtoC( <dDate>[, <cDateFormat>] ) --> cDate
<dDate> is a date expression the value of which is converted to a character string.
The optional parameter <cDateFormat> is a character string specifying the date format used in the string returned by the function. This defaults to the current date format set via SET DATE.

DtoC() returns a date value as a character string. The return value is formatted according to the date format specified in <cDateFormat>. With an empty date, a string of blank spaces equal in length to this date format is returned.


DtoC() is a conversion function which can be used to format date values when the date needs to be displayed as a character string. The returned string is in the format specified in the optional parameter <cDateFormat>. By default, this is the current date format set via SET DATE.

When a date value is used in the index key of an INDEX file, the function DtoS() must be used instead of DtoC() for correct sorting of date values.

// The example shows results of the function DtoC() 

   SET DATE FORMAT TO "mm/dd/yyyy" 

   ? Date()                     // -> 12/06/2020 
   ? DtoC(Date())               // -> "12/06/2020" 
   ? DToC(Date(), "") // -> "06.12.2020" 
   ? "New Year's Eve is on " + ; 
     DtoC(Date()+25)            // -> "New Year's Eve is on 12/31/2020!" 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.