Mimer SQL Documentation TOC PREV NEXT INDEX

Mimer SQL Developer Site


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, CAST Specification for more information.

Show the exchange rate for the US Dollar with 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:

0.7839

Retrieve the EAN, price and release date for any items released in 1987. Convert the release date (DATE'YYYY-MM-DD') to character with the format MM/DD/YY:
 SELECT ean_code, price,
        SUBSTRING(CAST(release_date AS CHAR(26)) FROM 11 FOR 2)
        || '/' ||
        SUBSTRING(CAST(release_date AS CHAR(26)) FROM 14 FOR 2)
        || '/' ||
        SUBSTRING(CAST(release_date AS CHAR(26)) FROM 8 FOR 2) AS date
    FROM items
    WHERE EXTRACT(YEAR FROM release_date) = 1987;
Returns:

EAN_CODE
PRICE
 DATE
9780006167242
4.99
 04/30/87
9780002315432
15.99
 06/15/87


Mimer
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
info@mimer.se
Mimer SQL Documentation TOC PREV NEXT INDEX