Converts a value from one data type to another.
Category: | Special |
Alias: | When expression is the name of a table column, the operator “::”can be used in the place of the CAST keyword. |
Returned data type: | The target data type. |
specifies any valid SQL expression.
Data type | Expression can resolve to any FedSQL data type supported by the data source. |
See | <sql-expression> |
FedSQL Expressions | |
Data Type Reference |
Is the target data type. See “Details” for information about supported data type conversions.
Restriction | The target data type must be supported by FedSQL and by the data source. |
See | Data Types |
Data Type Reference |
Is an optional integer that specifies the length of the target data type. The length argument is intended for use with character values. It is important when specifying literals. When a literal value is specified, the default value is 0, and the length needs to be at least as long as the number of characters that will be generated by the CAST.
Statements
|
Results
|
---|---|
select cast(begintime as DATE) from custonline; |
01SEP2013 02OCT2013 15OCT2013 01NOV2013 01DEC2013 02JAN2013 16JAN2013 01FEB2013 01MAR2013 15MAR2013 |
select si::integer as int from integers; |
32767 |
select bi::bigint * 2::bigint as bigbang from integers; |
ERROR: Numeric value out of range |
select cast ('2014-04-10' as DATE); |
10APR2014 |
select cast ('2014-04-10 10:56:49' as TIMESTAMP); |
10APR2014:10:56:49 |
select cast ('10:56:49' as TIME); |
10:56:49 |