Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Substr Vs. to_date(to_char) function

170739Nov 22 2002
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 23 2002
Added on Nov 22 2002
6 comments
2,383 views