The following database view truncates the date to the fiscal year (April 1st):
CREATE OR REPLACE VIEW FISCAL_YEAR_VW AS
SELECT
CASE
WHEN to_number(to_char(SYSDATE, 'MM')) < 4 THEN
to_date('1-APR-'||to_char(add_months(SYSDATE, -12), 'YYYY'), 'dd-MON-yyyy')
ELSE
to_date('1-APR-'||to_char(SYSDATE, 'YYYY'), 'dd-MON-yyyy')
END AS fiscal_year
FROM
dual;
This allows us to calculate the current fiscal year based on today's date.
How can this calculation be simplified or optimized?
ADD_MONTHS(TRUNC(ADD_MONTHS(SYSDATE,-3),'YYYY'),3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With