Skip to Main Content

Oracle Database Discussions

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!

Conditional REGEXP_REPLACE

662798Dec 18 2009 — edited Dec 18 2009
Basically what I am trying to accomplish is a conditional replacement of a string. For example, I run a function to return the quarter number with 4-digit year.

SELECT TO_CHAR(sysdate,'Q YYYY') FROM dual;

Gives me '4 2009'.

However, what I really want to display is 'Fourth Quarter 2009'. If it had returned '1 2009', I'd want 'First Quarter 2009', etc.

How could I create a conditional replacement so that I can get the textual representation of the quarter ('First Quarter 2009' instead of '1 2009')?

I was able to accomplish this via chained REPLACE functions but this seems a bit of a cludge. There must be a way to do this via regular expressions.

Any help would be much appreciated!
This post has been answered by Centinul on Dec 18 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 15 2010
Added on Dec 18 2009
6 comments
687 views