Cast conversions
You can use cast(<value> as <datatype>) to cast a data type from one type to another type. For example, you can convert any numeric data type (byteint, smallint, int, bigint, numeric/decimal, float, double) to any other numeric data type. The <value> field can be a column or an expression.
In addition to the cast function, more data type conversions are offered, as described in the
following table.
Data type | Function |
---|---|
numeric to a string | to_char(numeric,text) |
real or double precision to a string | to_char(double precisions, text) |
timestamp to a string | to_char(timestamp,text) |
string to date | to_date(text,template) |
string to numeric | to_number(text,template) |
string to timestamp | to_timestamp(text,text) |
You can also convert from one date, time, or timestamp
to another. For example:
NZSQL nzdw -a -x < x.sql
To convert a timestamp to a date, use CAST. For
example:
CAST(<timestamp_value> AS DATE);