Contents IndexUser-defined data types Year 2000 compliance

User's Guide
   Part VI. SQL Anywhere Reference
     Chapter 41. SQL Anywhere Data Types
      Data type conversions

Type conversions happen automatically, or they can be explicitly requested using the CAST or CONVERT function.

If a string is used in a numeric expression or as an argument to a function expecting a numeric argument, the string is converted to a number before use.

If a number is used in a string expression or as a string function argument, then the number is converted to a string before use.

All date constants are specified as strings. The string is automatically converted to a date before use.

There are certain cases where the automatic database conversions are not appropriate.

     '12/31/90' + 5 -- SQL Anywhere tries to convert the string to a number
     'a' > 0 -- SQL Anywhere tries to convert 'a' to a number

The CAST or CONVERT functions can be used to force type conversions. For information about the CAST and CONVERT functions, see "Data type conversion functions".

The following functions can also be used to force type conversions (see "Watcom-SQL Functions").

DATE( value )     Converts the expression into a date, and removes any hours, minutes or seconds. Conversion errors may be reported.

STRING( value ) similar to CAST( value AS CHAR ), except that string( NULL ) is the empty string (''), while CAST( NULL AS CHAR ) is the NULL value.

VALUE+0.0 Equivalent to CAST( value AS DECIMAL ).

Contents IndexUser-defined data types Year 2000 compliance