Google News
logo
Oracle - Interview Questions
Explain the Conversion function in detail?
Conversion Functions convert a value from one data type to another. Conversion functions are of two types:
 
Implicit Data type conversion :
 
* VARCHAR2 or CHAR To NUMBER, DATE
* NUMBER To VARCHAR2
* DATE To VARCHAR2

Explicit data type conversion :
 
* TO_NUMBER
* TO_CHAR
* TO_DATE

TO_NUMBER function is used to convert a Character string to Number format. TO_NUMBER function use fx modifier. Format: TO_NUMBER ( char[, ‘ format_model’] ). fx modifier specifies the exact matching for the character argument and number format model of the TO_NUMBER function.
 
TO_CHAR function is used to convert NUMBER or DATE data type to CHARACTER format. TO_CHAR Function uses fm element to remove padded blanks or suppress leading zeros. TO_CHAR Function formats : TO_CHAR (date, ‘format_model’).The format model must be enclosed in single quotation marks and is case sensitive.
 
Ex : Select TO_CHAR (hire date, ‘MM/YY’) from the employee.
 
TO_DATE function is used to convert a Character string to date format. TO_DATE function use fx modifier which specifies the exact matching for the character argument and date format model of TO_DATE function. TO_DATE function format: TO_DATE ( char[, ‘ format_model’] ).
 
Ex : Select TO_DATE (‘May 24, 2007’,’ mon dd RR’) from dual;
Advertisement