Sunday, September 30, 2007

Conversion Functions

Overview
This practice covers the following topics:
• Writing a query that displays the current date
• Creating queries that require the use of numeric, character, and date functions.
Data-type conversion
Implicit Data-Type Conversion
For assignments, the Oracle server can automatically convert the following:
Implicit Data-Type ConversionFor expression evaluation, the Oracle Server can automatically convert the following:


Explicit Data-Type Conversion
Explicit Data-Type Conversion

Using the TO_CHAR Function with Dates
TO_CHAR Function
The format model:
• Must be enclosed in single quotation marks and is case sensitive
• Can include any valid date format element
• Has an fm element to remove padded blanks or suppress leading zeros
• Is separated from the date value by a comma.


Elements of the Date Format Model
Elements of the Date Format Model• Time elements format the time portion of the date.
• Add character strings by enclosing them in double quotation marks.
• Number suffixes spell out numbers.


Using the TO_CHAR Function with Dates
TO_CHAR Function

Using the TO_CHAR Function with Numbers
TO_CHAR Function with NumbersThese are some of the format elements you can use with the TO_CHAR function to display a number value as a character:


Using the TO_NUMBER and TO_DATE Functions
• Convert a character string to a number format using the TO_NUMBER function:
TO_NUMBER function• Convert a character string to a date format using the TO_DATE function:
TO_DATE function• These functions have an fx modifier. This modifier specifies the exact matching for the character argument and date format model of a TO_DATE function.


RR Date Format

RR Date FormatExample of RR Date Format

2 comments:

Anonymous said...

Hey...
Good notes... I'm an Oracle DBA!!! So m used 2 read ths stuff... still, it's a good way 2 keep all concepts @ a single place... infact, i luv bloggin!!! :) keep it up... n very good luck for Database Tech... !!!

Rishi Saxena said...

Thanx shruti.