Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is the difference between to_char and to_date
functions?

Answers were Sorted based on User's Feedback



what is the difference between to_char and to_date functions?..

Answer / rajesh

to_char function is used to convert the given data into
character....
eg:to_char(sysdate,'month') which returns month alone...

to_date is used to convert the given data into date data
formate data type....

eg: to_date('070903', 'MMDDYY') would return a date value
of July 9, 2003.

Is This Answer Correct ?    138 Yes 33 No

what is the difference between to_char and to_date functions?..

Answer / jacob

try this out
select to_char(sysdate,' Day "," DDsp"th " Month Year') from
dual

this gives the day,date,month,year of the current date

Is This Answer Correct ?    43 Yes 15 No

what is the difference between to_char and to_date functions?..

Answer / kushal

to_char is used to convert dates into a character
representation, for example, if you want your query to
format the date differently:

i.e.
SELECT TO_CHAR(SYSDATE, 'DD/MM/YYYY HH24:MI:SS') FROM
dual; --> 09/06/2004 12:57:54
SELECT TO_CHAR(SYSDATE, 'Day ddth Month') FROM
dual; --> Wednesday 09th June

The to_date function is used when you have character input,
but need it as a date object (for example when the database
column is a Date, you need to insert a date)

i.e.
SELECT TO_DATE('01/01/2004', 'DD/MM/YYYY') FROM dual
SELECT TO_DATE('01/01/2004 13:13:13', 'DD/MM/YYYY
HH24:MI:SS') FROM dual

@madhu:-sysdate bydefault gives the date in
dateformat,which is prerequisite of the to_char.
For other dates we have to convert first in date format and
then operate to_char accordingly to change the format as
needed for the date.

Is This Answer Correct ?    31 Yes 4 No

what is the difference between to_char and to_date functions?..

Answer / sanjukata

to_char()is required to convert number type and date type
of value to character type.

try this
select ename,hiredate,to_char(hiredate,'day ddth mon yy')
from emp;

to_date()is required to convert charater type of value to
date type.
try this
select to_date('22092010','dd-mm-yy')from dual;

Is This Answer Correct ?    15 Yes 3 No

what is the difference between to_char and to_date functions?..

Answer / naveen

to_char function is used to convert the given data into
character....
eg:to_char(sysdate,'month') which returns month alone...

to_date is used to convert the given data into date data
formate data type....

eg: to_date('070903', 'MMDDYY') would return a date value
of July 9, 2003.

Is This Answer Correct ?    10 Yes 0 No

what is the difference between to_char and to_date functions?..

Answer / sushant butta

Check the answer in detail here. http://www.oraclebin.com/2012/12/what-is-difference-between-tochar-and.html

A lot of people have confusion about the usage of to_char and to_date functions. When to use to_char and when to use to_date. Here I am going to tell you how to do that. I will be discussing to_char function with respect to date only and not with numbers.

Syntax
to_char(value , format_mask)

to_date(string , format_mask)

So when you want to convert a date to a string use to_char function. Always remember that INPUT to to_char function is always a date (excluding numbers here). A format mask over here decides how OUTPUT of to_char function will look. Lets consider this with an example.



sql > Select to_char(sysdate,'DD-MM-YYYY') from dual;

Output : 01-01-2001

INPUT -> sysdate ( a date)
OUTPUT -> 01-01-2001 ( DD-MM-YYYY the format mask)

And when you want to convert a string to a date use to_date function. Always remember that OUTPUT of to_date function is always a date. A format mask over here decides what will the format of INPUT string. Lets have an example.

sql > select to_date( '01-01-2001','DD-MM-YYYY') from dual;

Output : 01-JAN-01

INPUT -> 01-01-2001 ( format_mask is 'DD-MM-YYYY')
OUTPUT -> 01-JAN-01 ( a date, the format here is the default NLS setting for your date)


Just remember the input and output of these functions and you will never make a mistake.

Is This Answer Correct ?    8 Yes 4 No

what is the difference between to_char and to_date functions?..

Answer / madhu

The Simple examples is correct but we take the date in date
format not like sysdate or hiredate.
if u select to_char('some date') and to_date('somedate')
explain with this examples if any one know.

Is This Answer Correct ?    7 Yes 6 No

what is the difference between to_char and to_date functions?..

Answer / m

to_char conversion function will convert given data to character data whereas to_data will convert given character data into date format model.


Also we can say like to_char conversion function use for convert invalid data into valid data.
and to_date conversion function will convert valid data into invalid.

Is This Answer Correct ?    1 Yes 0 No

what is the difference between to_char and to_date functions?..

Answer / susan

To_char is to convert number or date(string format) to character format.
To_date is from character format to date,only fetches d data when dere s valid number..

Is This Answer Correct ?    2 Yes 5 No

what is the difference between to_char and to_date functions?..

Answer / xc

cxc

Is This Answer Correct ?    5 Yes 22 No

Post New Answer

More SQL PLSQL Interview Questions

What is a mutating table

5 Answers   TCS, Tech Mahindra,


What are all the different normalizations?

0 Answers  


What is sql*loader and what is it used for?

0 Answers  


How can u find column name from a table which have max value in a row.( not max value)

5 Answers  


Which one is faster ienumerable or iqueryable?

0 Answers  


Explain two virtual tables available at the time of database trigger execution.

1 Answers  


select sal from emp group by sal

3 Answers   TCS,


What is data abstraction in sql?

0 Answers  


What are the types of dbms?

0 Answers  


How you will create Toad Function?

1 Answers  


What are stuff and replace function?

0 Answers  


What is the difference between delete, truncate and drop command?

0 Answers  


Categories