Fiscal Year

Bone_12 361 Reputation points
2022-10-31T10:00:57.967+00:00

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?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,705 questions
Azure Database for PostgreSQL
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 112.1K Reputation points
    2022-10-31T11:04:22.287+00:00

    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  
    
    0 comments No comments

  2. Tom Phillips 17,716 Reputation points
    2022-10-31T12:31:06.833+00:00

    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/

    0 comments No comments