Converts a date into a literal date string.

Syntax

DTOC(<expD>)

<expD>

The date to return as a string.

Description

There are many different ways to represent a date as a string. Use DTOC( ) to convert a date into a literal date string, one that is suitable for conversion back into a date by CTOD( ).

The order of the day, month, and year is controlled by the current SET DATE setting. Whether the year is expressed as two or four digits is controlled by SET CENTURY. The separator character is controlled by SET MARK.

Note

To convert a date expression to a character string suitable for indexing or sorting, always use DTOS( ), which converts the date into a consistent and sortable format.

If you pass a blank date to DTOC( ), it returns a string with spaces instead of digits. For example, if the SET DATE format is AMERICAN and SET CENTURY is OFF, DTOC({ }) returns " / / ".

When concatenating a date to a string, dBASE Plus automatically converts the date using DTOC( ) for you.