Home » SQL & PL/SQL » SQL & PL/SQL » Fiscal Year SQL query
Fiscal Year SQL query [message #340187] Mon, 11 August 2008 18:47 Go to next message
bztom33
Messages: 95
Registered: June 2005
Member
Hi,

I would like to generate a list of 5 previous and future fiscal year from the current fiscal year.

This query generates only the current fiscal year.

select to_char(sysdate ,'YYYY'),to_char(sysdate + 365, 'YYYY') from dual;


Thanks,

Tom


Re: Fiscal Year SQL query [message #340188 is a reply to message #340187] Mon, 11 August 2008 18:50 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & follow posting guidelines as stated in URL above

search this forum for "calendar".
Re: Fiscal Year SQL query [message #341056 is a reply to message #340187] Fri, 15 August 2008 22:48 Go to previous messageGo to next message
bztom33
Messages: 95
Registered: June 2005
Member
I solved the problem.
Re: Fiscal Year SQL query [message #341057 is a reply to message #341056] Fri, 15 August 2008 22:57 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
bztom33 wrote on Fri, 15 August 2008 20:48
I solved the problem.


Please share the solutions so other may benefit.
Re: Fiscal Year SQL query [message #341223 is a reply to message #341057] Sun, 17 August 2008 21:40 Go to previous messageGo to next message
bztom33
Messages: 95
Registered: June 2005
Member
I did not rely entirely from the SQL query to generate a list of fiscal years.

I get the current and next fiscal year from the following query.

select to_char(sysdate ,'YYYY'),to_char(sysdate + 365, 'YYYY') from dual;


The key thing is to get the current and next fiscal year from Oracle SQL query, then I can generate the rest of the fiscal years programmatically out side of Oracle query in a for loop.






Re: Fiscal Year SQL query [message #341247 is a reply to message #341223] Sun, 17 August 2008 23:44 Go to previous message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What happened to your query when you executed it on 01-JAN-2008?

Why don't you want to do it in a single SQL?
Why if you can know the other years programmatically, you can't know the current and next ones in the same way? I don't know any language that can't return you the current year.

Regards
Michel
Previous Topic: Trigger Error + the declaration of the type of this expression is incomplete or malformed
Next Topic: Unable to inser data -ORA-00917
Goto Forum:
  


Current Time: Sun Dec 11 02:31:40 CST 2016

Total time taken to generate the page: 0.07064 seconds