Take the 2-minute tour ×

How should I write a function to calculate the fiscal year and the quarter when user provides a date.Please reply soon.

share|improve this question
Since different companies have different fiscal years (and thus different fiscal quarters), it would be helpful to define what fiscal year your company uses. Something like "the company's fiscal year 2012 starts June 1, 2011". –  Justin Cave Jun 27 '11 at 7:45
Are you talking about the United States? –  Álvaro G. Vicario Jun 27 '11 at 7:52
add comment

1 Answer

Different companies start the fiscal year on different dates so the specifics of the implementation will depend on the specifics of how your company defines the fiscal year. If, for example, fiscal year 2012 starts June 1, 2011

SELECT to_char( add_months( <<input date>>, 7 ), 'YYYY' ) fiscal_year,
       to_char( add_months( <<input date>>, 7 ), 'Q' ) fiscal_quarter
  FROM dual;

If your company starts the fiscal year at a different point, you'd adjust the 7 month offset to whatever offset gets you to January 1 of the next calendar year.

share|improve this answer
add comment

Your Answer


