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!

Return year, quarter, month and week from a date

573145Apr 23 2008 — edited Apr 24 2008

I use this to convert a date filed to year_week, year_month, year_quarter and year.
But when I use it in views I got problem with queries, they take long time...
Is this the best way to do this?

Select  to_char(rec_date, 'yyyy') || to_char(rec_date, 'IW') As year_week,
        to_char(rec_date, 'yyyy') || to_char(rec_date, 'mm') As year_month,
        to_char(rec_date, 'yyyy') || '0' || to_char(rec_date, 'q') As year_quarter,
        to_char(rec_date, 'yyyy') As year
FROM tbltest
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 22 2008
Added on Apr 23 2008
9 comments
880 views