Function DtoS() Foundation

Converts a date value to a character string in the format YYYYMMDD.

Syntax
DtoS( <dDate> ) --> cDate
Parameters
<dDate>
<dDate> is a date expression whose value is converted to a character string.
Return

DtoS() returns a character string of eight characters in the format YYYYMMDD. If <dDate> is an empty date (CtoD("")), DtoS() returns eight blank spaces. The current date format (SET DATE) has no influence on the return value.

Description

DtoS() is a conversion function which transforms a date value to a character string with the format YYYYMMDD (year, month and day). It is used to provide correct sorting when date values are combined with other values in an index expression.

Examples
DtoS()
// The example shows the result of the function DtoS() and 
// compares it to Date(). 

PROCEDURE Main 

   ? Date()                      // result: 12/06/94 
   ? DtoS(Date())                // result: 19941206 
   ? Len(DtoS(CtoD("")))         // result: 8 

RETURN 

Use a date value for an index key

// In the example, an index is created using the 
// function DtoS() in the index key (which consists 
// of a date and two character strings). 

PROCEDURE Main 

   USE Order NEW EXCLUSIVE 
   INDEX ON DtoS(date) + orderNr + PartNo TO order1 

RETURN 
Feedback

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.