How to convert 2011 -Q4
to 12-31-2011
in Oracle sql?
Advertisement
Answer
This expression should work to transform the value into the date:
select add_months(to_date(substr(yq, 1, 4)||'-01-01', 'YYYY-MM-DD'), substr(yq, -1, 1) * 3) - interval '1' day from (select '2011-Q4' as yq from dual) x
If you want the date as a particular string format, then use to_char()
.