ICONV function

Syntax

ICONV (string, conversion)

Description

Use the ICONV function to convert string to a specified internal storage format. string is an expression that evaluates to the string to be converted.

conversion is an expression that evaluates to one or more valid conversion codes, separated by value marks (ASCII 253).

string is converted to the internal format specified by conversion. If multiple codes are used, they are applied from left to right. The first conversion code converts the value of string. The second conversion code converts the output of the first conversion, and so on.

If string evaluates to the null value, null is returned. If conversion evaluates to the null value, the ICONV function fails and the program terminates with a run-time error message.

The STATUS function reflects the result of the conversion:

0
The conversion is successful.
1
string is invalid. An empty string is returned, unless string is the null value, in which case null is returned.
2
conversion is invalid.
3
Successful conversion of possibly invalid data.

For information about converting strings to an external format, see the OCONV function.

Examples

The following are examples of date conversions:

Source Line
Converted Value
DATE=ICONV("02-23-85","D")
6264
DATE=ICONV("30/9/67","DE")
-92
DATE=ICONV("6-10-85","D")
6371
DATE=ICONV("19850625","D")
6386
DATE=ICONV("85161","D")
6371

The following is an example of a time conversion:

Source Line
Converted Value
TIME=ICONV("9AM","MT")
32400

The following are examples of hex, octal, and binary conversions:

Source Line
Converted Value
HEX=ICONV("566D61726B","MX0C")
Vmark
OCT=ICONV("3001","MO")
1537
BIN=ICONV(1111,"MB")
15

The following are examples of masked decimal conversions:

Source Lines
Converted Value
X=4956.00 X=ICONV(X,"MD2")
495600
X=563.888 X=ICONV(X,"MD0")
-564
X=ICONV(1988.28,"MD24")
19882800