ALLBASE/SQL Reference Manual (36216-90216)

Chapter 8 245
Expressions
Date/Time Functions
Date/Time Functions
The following text describes the two types of date/time conversion functions:
The input functions convert character values into date/time values. With TO_DATE,
TO_TIME, TO_DATETIME, and TO_INTERVAL you can enter date/time values in a
format other than the default format.
The output functions convert date/time values out to integer or character values. With
TO_CHAR you can specify an output format for a date/time column value other than
the default format. With TO_INTEGER you can extract an element as an INTEGER
value.
Date/time columns are displayed in the default format.
Scope
SQL Data Manipulation Statements
SQL Syntax—Conversion Functions
{ { TO_DATE
TO_TIME
TO_DATETIME
TO_INTERVAL } (
StringExpression
[,
FormatSpecification
])
TO_CHAR (
DateTimeExpression
[,
FormatSpecification
])
TO_INTEGER (
DateTimeExpression
,
FormatSpecification
)}
Parameters—Conversion Functions
TO_DATE, TO_TIME,
TO_DATETIME, TO_INTERVAL produce a result which is of the DATE, TIME,
DATETIME, or INTERVAL type, respectively. Use these
functions in any expression.
TO_CHAR produces the character string representation of the value
in the column named in the first parameter in the format
specified in the second parameter. The result type is
VARCHAR with the length as specified by the format
specification. If a format is not specified, the default
format for the data type (and length) is used. Use this
output function in any expression.
TO_INTEGER produces an INTEGER value which represents a portion of
the date/time column. The format specification is not
optional in this case, and must consist of a single element
(of the format specification). Use this output function in
any expression.
StringExpression
is a string expression. Refer to the "Expression" section in
this chapter for details on the syntax. The expression must