How to calculate Australian Financial Year from a date column in SQL?

Viewed 215

I have a table called Sales with a date column called SaleDate. How can I write a SQL query that shows the Australian financial year in addition to the other columns?

More details:

  • I use Microsoft SQL Server
  • The Australian financial year starts on 1 July and ends the next year on 30 June.
    • Example 1: 10 June 2019 is FY 2019
    • Example 2: 5 July 2019 is FY 2020
1 Answers

For Microsoft SQL Server, the following query will show a new column called FY, which represents the Australian financial year.

SELECT
    year(dateadd(MONTH, 6, SaleDate)) AS FY,
    SaleDate,
    Item
FROM Sales
Related