开发者

Calculate fiscal year and quarter

开发者 https://www.devze.com 2023-03-15 09:38 出处:网络
How should I write a function to calculate the fiscal year an开发者_运维知识库d the quarter when user provides a date.Please reply soon.Different companies start the fiscal year on different dates so

How should I write a function to calculate the fiscal year an开发者_运维知识库d the quarter when user provides a date.Please reply soon.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号