"DateTime to Character" converts a DateTime value to a literal DateTime string.

Syntax

DTTOC(<dtVar>)

<dtVar>

A DateTime variable or value

Description

Use DTTOC( ) to convert a DateTime value into a literal DateTime string.

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.

Once the DateTime value has been converted to a character string, it's integral parts, DATE and TIME, can be extracted using the LEFT( ) or RIGHT( ) functions. When SET CENTURY is OFF, the date and time strings can be extracted using

  left("value",8) and right("value",11) respectively.

Note

To recombine extracted date and time values into a DateTime format, see CTODT( ) (Character to DateTime)