Mimer SQL User's Manual TOC PREV NEXT INDEX

Mimer Developer Site

www.mimer.com/developer


Using 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 for conversion rules.

List the billed charges for reservation number 1347. Convert the charged amounts to US-dollars to decimal with scale 4. Convert the date of charges (in format YYYY-MM-DD) to character in format DD/MM/YY.
 SELECT CAST(CHARGE_CODE AS SMALLINT) AS CODE,
        CAST(COST/7.835 AS DECIMAL(10,4)) AS USD,
        SUBSTRING(CAST(ON_DATE AS CHAR(26)) FROM 9 FOR 2)||'/'||
        SUBSTRING(CAST(ON_DATE AS CHAR(26)) FROM 6 FOR 2)||'/'||
        SUBSTRING(CAST(ON_DATE AS CHAR(26)) FROM 3 FOR 2) AS DATE
 FROM   BILL
 WHERE  RESERVATION = 1347
 ORDER BY CODE;
Result:

 CODE
 USD
 DATE
 100
  12.7632
 21/08/97
 120
  5.1052
 21/08/97
 120
  5.1052
 21/08/97
 210
 -
 21/08/97
 700
 -
 21/08/97



Upright Database Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
dbtechnology@upright.se
Mimer SQL User's Manual TOC PREV NEXT INDEX