How to get last financial year data in access (1 Viewer)

hrdpgajjar

Registered User.
Local time
Today, 17:37
Joined
Sep 24, 2019
Messages
51
Hi there,
I've create two functions to get data of current financial year (1st April to 31st March) as under,

1. Financial year start function,


Code:
Public Function fnFinancialYearStart(Optional ByVal start_date As Date = 1) As Date
Dim x_date As Date
If start_date = 1 Then
start_date = Date
End If
x_date = DateSerial(Year(start_date), 4, 1)
If start_date < x_date Then
x_date = DateAdd("yyyy", -1, x_date)
End If
fnFinancialYearStart = x_date
End Function

2. Financial Year End Function,


Code:
Public Function fnFinancialYearEnd(Optional Byval start_date As Date = 1) As Date
start_date = fnFinancialYearStart(start_date)
fnFinancialYearEnd = DateAdd("yyyy", 1, start_date) - 1
End Function

Both the functions works correctly. But now I need to get data from last financial year to compare with current Financial year. I've tried to modify the start and end financial year functions but it not works. it breaks my current year data. So kindly help me how can i get last financial year data.


Thanks
 

jdraw

Super Moderator
Staff member
Local time
Today, 08:07
Joined
Jan 23, 2006
Messages
15,379
Is this a continuation of the thread referenced in the Similar Threads?

Looks like it was solved in July 2021???

Please give readers some context.
 

Minty

AWF VIP
Local time
Today, 13:07
Joined
Jul 26, 2013
Messages
10,368
Just use your function and subtract a year from the dates returned?

fnFinancialYearStart(Date()) = This FY Start
Dateadd("yyyy",-1, fnFinancialYearStart(Date()) ) = Previous FY Start
 

Users who are viewing this thread

Top Bottom