4. Elements of QUEL Statements : Functions : Scalar : Data Type Conversion Functions
 
Share this page                  
Data Type Conversion Functions
The following table lists the data type conversion functions:
Name
Operand Type
Result Type
Description
c(expr [, len])
any
c
Converts argument to c string. If you specify the optional length argument, the function returns the leftmost len characters. Len must be a positive integer value that does not exceed the length of the expr string.
char(expr [, len])
any
char
Converts argument to char string. If you specify the optional length argument, the function returns the leftmost len characters. Len must be a positive integer value that does not exceed the length of the expr string.
date(expr)
c, text, char, varchar
date
Converts a c, char, varchar or text string to internal date representation.
dow(expr)
date
c
Converts an absolute date into its day of week (for example, "Mon," "Tue"). The result length is 3.
float4(expr)
c, char, varchar, text, float, money, and the integer data types
float4
Converts the specified expression to float4.
float8(expr)
c, char, varchar, text, float, money, and the integer data types
float
Converts the specified expression to float.
hex(expr)
varchar, char, c, text
varchar
Returns the hexadecimal representation of the argument string. The length of the result is twice the length of the argument, because the hexadecimal equivalent of each character requires two bytes. For example, hex("A") returns "61" (ASCII) or "C1" (EBCDIC).
int1(expr)
c, char, varchar, text, float, money, and the integer data types
i1
Converts the specified expression to i1. Floating point values are truncated. Numeric overflow occurs if the integer portion of a floating point value is too large to be returned in the requested format.
int2(expr)
c, char, varchar, text, float, money, and the integer data types
i2
Converts the specified expression to i2. Floating point values are truncated. Numeric overflow occurs if the integer portion of a floating point value is too large to be returned in the requested format.
int4(expr)
c, char, varchar, text, float, money, and the integer data types
i4
Converts the specified expression to i4. Floating point values are truncated. Numeric overflow occurs if the integer portion of a floating point value is too large to be returned in the requested format.
money(expr)
c, char,
varchar,
text,
float,
and the integer data types
money
Converts the specified expression to internal money representation. Rounds floating point values, if necessary.
text(expr [, len])
any
text
Converts argument to text string. If you specify the optional length argument, the function returns the leftmost len characters. Len must be a positive integer value that does not exceed the length of the expr string.
varchar(expr [, len])
any
varchar
Converts argument to varchar string. If you specify the optional length argument, the function returns the leftmost len characters. Len must be a positive integer value that does not exceed the length of the expr string.
If you omit the optional length parameter, the length of the result returned by data type conversion functions c(), char(), varchar(), and text() are as follows:
Data Type of Argument
Result Length
c
Length of operand
char
Length of operand
date
25 characters
float & float4
11 characters; 12 characters on IEEE computers
integer1 (smallint)
6 characters
integer
6 characters
integer4
13 characters
long varchar
Length of operand
money
20 characters
text
Length of operand
varchar
Length of operand