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
What is the plv (pl/vision) package offers?
what are null values? : Sql dba
What is the use of stored procedures?
How do you use join?
Why do we use procedures in pl sql?
what is union? : Sql dba
What is rownum and rowid?
Is vs as in pl sql?
What is scope of pl sql developer in future?
What will you get by the cursor attribute sql%found?
Can we alter stored procedure?
Can a foreign key have a different name?
How to fetch alternate records from a table?
What is union, minus and interact commands?
How to call a javascript function from pl sql?