Home » SQL & PL/SQL » SQL & PL/SQL » Getting Financial Year Begining (9.2.0.7)
Getting Financial Year Begining [message #422583] Thu, 17 September 2009 08:48 Go to next message
Brayan
Messages: 315
Registered: June 2002
Senior Member
Hi,

Our financial year starts from 01-Apr-2009 and end on 31-Mar-2010.

I have written following script to extract the same. It is more lengthy. Does anybody has better script than this.

select 		
	decode(to_char(sysdate,'Q'),1, 
				to_date('01-APR-'||to_char(to_number(to_char(sysdate,'YYYY'))-1),'DD-MON-YYYY'), 
				to_date('01-APR-'||to_char(sysdate,'YYYY'),'DD-MON-YYYY')
			)
from dual


Brayan
Re: Getting Financial Year Begining [message #422585 is a reply to message #422583] Thu, 17 September 2009 09:07 Go to previous messageGo to next message
Michel Cadot
Messages: 64133
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> with data as (select add_months(sysdate,level) dt from dual connect by level <= 12)
  2  select dt, extract(year from add_months(dt,-3)) fiscal_year
  3  from data
  4  /
DT                  FISCAL_YEAR
------------------- -----------
17/10/2009 16:07:09        2009
17/11/2009 16:07:09        2009
17/12/2009 16:07:09        2009
17/01/2010 16:07:09        2009
17/02/2010 16:07:09        2009
17/03/2010 16:07:09        2009
17/04/2010 16:07:09        2010
17/05/2010 16:07:09        2010
17/06/2010 16:07:09        2010
17/07/2010 16:07:09        2010
17/08/2010 16:07:09        2010
17/09/2010 16:07:09        2010

12 rows selected.

Regards
Michel
Re: Getting Financial Year Begining [message #422588 is a reply to message #422583] Thu, 17 September 2009 09:51 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
>select add_months(trunc(sysdate,'year'),3) ,add_months(trunc(sysdate,'year'),15)-1 from dual;

ADD_MONTH ADD_MONTH
--------- ---------
01-APR-09 31-MAR-10

[Updated on: Thu, 17 September 2009 09:52]

Report message to a moderator

Previous Topic: Fetch and update a single record exclusively
Next Topic: ORA-12801: error signaled in parallel query server P000
Goto Forum:
  


Current Time: Thu Dec 08 03:50:12 CST 2016

Total time taken to generate the page: 0.06927 seconds