Returning results that fall within the current financial year

  • Hi Everyone,

    I am using MSSQL Server 2008R2 and I am interested in returning rows from a 'financial' table that fall within the current year (each row contains a 'Entered Date'). I am located in Australia so my financial year consists of all entries between the date 01/07/xx to the 30/06/yy.

    Can anybody suggest some code, perhaps using the datediff() function, or other functions as required to achieve what I need?

    Kind Regards,

    David

  • Calculate fiscal year in SQL Server

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • WHERE

    [Entered Date] >= DATEADD(MONTH, 6, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE())

    - CASE WHEN MONTH(GETDATE()) < 7 THEN 1 ELSE 0 END, 0)) AND

    [Entered Date] < DATEADD(MONTH, 6, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE())

    - CASE WHEN MONTH(GETDATE()) < 7 THEN 1 ELSE 0 END + 1, 0))

    Edit: Split lines into two so all code is visible in the code window.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Thanks for the very helpful responses.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply