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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are database links used for?

988


Is sql workbench free?

927


Is like operator in sql case sensitive?

960


How do I make my sql query run faster?

889


What trigger means?

926


Is mariadb nosql?

988


What are the different type of joins in sql?

905


What is the execution plan in sql?

970


What is identity column in sql server?

985


What is database white box testing and black box testing?

1045


What is integrity in sql?

979


How do I view tables in mysql?

912


What are the methods of filing?

871


Does pl sql work in mysql?

918


How can you save or place your msg in a table?

952