Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » UltraLite - Database Management and Reference » UltraLite SQL Reference » UltraLite SQL function reference » Alphabetical list of functions


CAST function [Data type conversion]

Returns the value of an expression converted to a supplied data type.

The CAST, CONVERT, HEXTOINT, and INTTOHEX functions can be used to convert to and from hexadecimal values. For more information on using these functions, see Converting to and from hexadecimal values.

CAST( expression AS datatype )
  • expression   The expression to be converted.

  • data type   The target data type.


If you do not indicate a length for character string types, the database server chooses an appropriate length. If neither precision nor scale is specified for a DECIMAL conversion, the database server selects appropriate values.

See also
Standards and compatibility
  • SQL/2003   Core feature.


The following function ensures a string is used as a date:

SELECT CAST( '2000-10-31' AS DATE );

The value of the expression 1 + 2 is calculated, and the result is then cast into a single-character string.


You can use the CAST function to shorten strings

SELECT CAST ( 'Surname' AS CHAR(5) );