Explicit Data Type Conversion (CAST and CONVERT)

In BBj 7.0 and higher, the BBj SQL engine provides two explicit data type conversion functions shown in the table below.

Function

Description

CONVERT(value-exp, data-type)

Converts the specified value expression to the specified data type and returns that value.

CAST(value-exp AS data-type)

Casts the specified value expression to the specified data type and returns that value.

See Supported Data Types for a list of supported data types for this function.

Example

SELECT CAST(my_date AS SQL_CHAR) FROM my_table

SELECT CONVERT(my_char, SQL_INTEGER) FROM my_table