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 with a release date in the future. Convert the release date (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:

EAN_CODE
PRICE
 DATE
7298976754871
13.98
 16/03/02
7464376662256
15.98
 23/03/02
9781990789861
13.99
 19/03/02
9781993789639
6.99
 15/03/02


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