Check this query too:
select date_app_in,
format(dateadd(month, -3, date_app_in), '"FY"yy"/"') + format(dateadd(month, 9, date_app_in), 'yy') as Fiscal_Year
from MyTable
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have a field called date_app_in which is formatted as yyyy-mm-dd
What I need to create if possible is a financial year flag that ideally would output something like FY22/23.
The financial year runs from April to March.
So if my date was between 1st April 2022 - 31st March 2023, I would like my new field (name Fiscal_Year_ to output as FY22/23.
Is that possible with my date variable?
Check this query too:
select date_app_in,
format(dateadd(month, -3, date_app_in), '"FY"yy"/"') + format(dateadd(month, 9, date_app_in), 'yy') as Fiscal_Year
from MyTable
Create a calendar table to calculate the value and never think about it again.
See:
https://weblogs.sqlteam.com/dang/2010/07/19/calendar-table-and-datetime-functions/