background image
<< CEIL or CEILING function | The COALESCE function >>

Datetime to character syntax

<< CEIL or CEILING function | The COALESCE function >>
Derby Reference Manual
120
CHAR (IntegerExpression )
IntegerExpression
An expression that returns a value that is an integer data type (either SMALLINT,
INTEGER or BIGINT).
The result is the character string representation of the argument in the form of an SQL
integer constant. The result consists of n characters that are the significant digits that
represent the value of the argument with a preceding minus sign if the argument is
negative. It is left justified.
· If the first argument is a small integer: The length of the result is 6. If the number
of characters in the result is less than 6, then the result is padded on the right with
blanks to length 6.
· If the first argument is a large integer: The length of the result is 11. If the number
of characters in the result is less than 11, then the result is padded on the right with
blanks to length 11.
· If the first argument is a big integer: The length of the result is 20. If the number of
characters in the result is less than 20, then the result is padded on the right with
blanks to length 20.
Datetime to character syntax
CHAR (DatetimeExpression )
DatetimeExpression
An expression that is one of the following three data types:
· date: The result is the character representation of the date. The length of the
result is 10.
· time: The result is the character representation of the time. The length of the
result is 8.
· timestamp: The result is the character string representation of the timestamp.
The length of the result is 26.
Decimal to character
CHAR (DecimalExpression )
DecimalExpression
An expression that returns a value that is a decimal data type. If a different precision
and scale is desired, the DECIMAL scalar function can be used first to make the
change.
Floating point to character syntax
CHAR (FloatingPointExpression )
FloatingPointExpression
An expression that returns a value that is a floating-point data type (DOUBLE or
REAL).
Example
Use the CHAR function to return the values for EDLEVEL (defined as smallint) as a fixed
length character string:
SELECT CHAR(EDLEVEL) FROM EMPLOYEE
An EDLEVEL of 18 would be returned as the CHAR(6) value '18 ' (18 followed by four
blanks).
COALESCE function