A selection of topics on IT and its application to finance.
Send me your comments, questions or suggestions by clicking here
Generate a list of quarter end dates between two dates
I had a requirement to generate a list of quarter end dates between 2 dates. The first Q end date had to be the quarter before the quarter that the start date was in and the final Q end date had to be the quarter that the end date was in. Here is my solution.
with quarters as
trunc(trunc(to_date('15-jun-12'),'month'),'Q') startdate ,
select add_months(startdate, level*3-3) -1 dt
where add_months(startdate, level*3-3)<=add_months(enddate,3)
connect by level <= months_between(enddate, startdate)
14 rows selected.