Fiscal Year dynamic function (Oracle SQL) My Fiscal Year starts on 1st October (2017) and ends 30th September (2018)

I want to write a function that will dynamically calculate first day of October.

Currently I have:

select Add_Months(Trunc(Add_Months(sysdate,3),'YYYY'), -3) from dual
create or replace function fiscal_year_start_date(p_date date) return date
as
  pragma udf;
begin
  return add_months(trunc(add_months(p_date,3),'YYYY'), -3);
end;
/

alter session set nls_date_format='YYYY-MM-DD';

select fiscal_year_start_date(date'2016-01-01') from dual;

FISCAL_YEA
----------
2015-10-01


pragma_udf is optional, it is a 12c feature that boosts performance of such user-defined functions a bit when used in plain SQL (but may degrade in PL/SQL).