Thursday 4 March 2010

Selecting beginning of financial year in Oracle

I recently had to work out how to return the beginning of the financial year from an Oracle database. After trawling the internet, everything looked rather complicated for what I was after.



Below is what I came up with. It's pretty simple to change. If April is not the month you want to return, change the +4 at the end to the number of the month you want to return.



select trunc(add_months(sysdate, - (12 + to_char(sysdate,'MM'))+4),'MM')
from dual

No comments: