Substr Vs. to_date(to_char) function
Hi Everybody,
Here is my question -
I have a field SSS VARCHAR2(8), which stores the date in the format MMDDYYYY.
I have to print this field in YYYYMMDD format. So, I have 2 days in mind -
1) Select Substr(sss,4,4)||substr(sss,1,2)||substr(sss,3,2) from <table_name>;
2) Select to_char(to_date(sss,'mm/dd/yyyy'),'yyyymmdd') from <table_name>;
What do you suggest is the best coding practice to convert it? What Oracle suggests for such conversions?
I think (2) is the best way to convert.
Please reply back immediately.
Thanks.