English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Working with dates in any database can cause some frustration. How do the TO_CHAR and TO_DATE functions help in working with date logic within Oracle?

2006-12-05 16:31:11 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

TO_CHAR can cast a DATE column to a human-readable string representing a date. TO_DATE can cast a human-readable string to a DATE type.

2006-12-05 16:34:44 · answer #1 · answered by Anonymous · 0 0

TO_CHAR can be used to change the format of a date or number into a character value based on the format. For example (in oracle),
select to_char(sysdate, 'yyyy/mm/dd') from dual;
select to_char(myVal,'9999.99') from mytable;

The TO_DATE function reverses this for dates. For example, to take a date literal of 12/31/1999 and store it into a date datatype column, you'd use
update mytable set mydate=to_date('12/31/1999','mm/dd/yyyy') where...

2006-12-06 00:40:02 · answer #2 · answered by BigRez 6 · 0 0

fedest.com, questions and answers