The STRING function allows you to convert ABL non-character data types to a character value. Many data types are supported, including:
  • INTEGER or INT
  • DECIMAL
  • LOGICAL
  • DATE
  • DATETIME
  • DATETIME-TZ

You can concatenate a string representing different data types, provided you first convert each non-character type to a string.

The STRING function syntax is shown:

STRING ( value [, "format-string" ] )
value

A variable, field, or an expression that evaluates to a numeric, date and time, or logical value.

format-string
The customized format for the string that is returned by this function.

Example: Use STRING() to create character data

You can create a message string from multiple values, some of which may not be CHARACTER types. In the following example code, the STRING function is used to convert a DATETIME value to a character string that is part of a concatenated message string.

VAR CHAR cTime.
VAR CHAR cDateStr.
VAR CHAR cTimeStr.

cDateStr = "Today's date is " + STRING(TODAY).

/* convert the current time to a string */
cTime = STRING(TIME, "hh:mm:ss am").

cTimeStr = "and the time is " + cTime.

MESSAGE cDateStr SKIP cTimeStr VIEW-AS ALERT-BOX.

The example code produces output similar to the following:

Today's date is 05/07/20 
and the time is 11:20:10 am