Connecting Tech Pros Worldwide Help | Site Map

CONVERSION FUNCTIONS

amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#1   Sep 17 '07
CONVERSION Functions:

TO_CHAR(m) - Retuns character type of integer m. This function is mainly used to display the date in desired format
Expand|Select|Wrap|Line Numbers
  1. SELECT TO_CHAR(10) FROM dual -- returns '10'
  2. SELECT TO_CHAR(SYSDATE,'DD-MON-RRRR HH12:MI:SS PM') FROM dual -- returns '14-SEP-2007 03:29:49 PM' 
  3.  
TO_DATE(string) - Returns DATE type of the string being passed to the function.
Expand|Select|Wrap|Line Numbers
  1. SELECT TO_DATE('01-JAN-2006') FROM dual -- returns '1/1/2006' (This Query will work only if NLS_DATE_FORMAT = 'DD-MON-RRRR')
  2.  
NLS_DATE_FORMAT can be altered useing ALTER SESSION command

TO_NUMBER(string) - Returns NUMBER type of the string being passed to the funtion
Expand|Select|Wrap|Line Numbers
  1. SELECT TO_NUMBER('10') FROM dual -- returns 10
  2.  



Closed Thread