Conditional REGEXP_REPLACE
662798Dec 18 2009 — edited Dec 18 2009Basically 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!