|
|
Using the CAST Specification
The CAST specification explicitly converts data of one data type to another data type.
Conversion between data types is allowed if the rules for assignment to the target data type are not violated. See the Mimer SQL Reference Manual, Chapter 8, CAST Specification for more information.
Show the exchange rate for the US Dollar if there was a 10% change, force the result to four decimal places:
SELECT CAST(exchange_rate * 0.90 AS DECIMAL(12, 4)) FROM currencies WHERE code = 'USD';Returns:
Retrieve the EAN, price and release date for any items with a release date in the future. Convert the release date (YYYY-MM-DD) to character with the format DD/MM/YY:
SELECT ean_code, price, SUBSTRING(CAST(release_date AS CHAR(26)) FROM 14 FOR 2) || '/' || SUBSTRING(CAST(release_date AS CHAR(26)) FROM 11 FOR 2) || '/' || SUBSTRING(CAST(release_date AS CHAR(26)) FROM 8 FOR 2) AS date FROM items WHERE release_date > CURRENT_DATE;Returns:
DATE 16/03/02 23/03/02 19/03/02 15/03/02
|
Upright Database Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 dbtechnology@upright.se |
|
|