Monday, July 7, 2008

First and Last Dates of a Quarter: Oracle Query

Below is one of the many queries (Oracle specific syntaxes) one can write to get the first and last days of all the four quarters in any year:

select
add_months(trunc(sysdate,'Y'),(3*(rownum-1))) ,last_day(add_months(add_months(trunc(sysdate,'Y'),(3*(rownum-1))),2))
from
all_indexes
where
rownum<5

No comments: