# Microsoft Access function return financial year based on a date value

I am using Microsoft Access 2000 and I wish to write a function to return a financial year based on a date value.
The financial year should be computed as follows:
Let rdate be the date (e.g. receipt date)
Let fyear be the financial year

If the rdate ranges from

1-Apr-2005 to 31-Mar-2006
then fyear should be 20052006

1-Apr-2006 to 31-Mar-2007
then fyear should be 20062007

1-Apr-2007 to 31-Mar-2008
then fyear should be 20072008

1-Apr-2008 to 31-Mar-2009
then fyear should be 20082009

1-Apr-2009 to 31-Mar-2010
then fyear should be 20092010

1-Apr-2010 to 31-Mar-2011
then fyear should be 20102011

1-Apr-2011 to 31-Mar-2012
then fyear should be 20112012

and so on, let us say for the next 50years
I do not have data prior to 1-Apr-2005
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
function GetFinYear(dt as Date) as String
If Month(dt) >= 4 then
GetFinYear = (Year(dt)-1) & Year(dt)
else
GetFinYear = Year(dt) & (Year(dt)+1)
end if
end function
0
Commented:
Wrong way around, sorry

Function GetFinYear(dt As Date) As String
If Month(dt) >= 4 Then
GetFinYear = Year(dt) & (Year(dt) + 1)
Else
GetFinYear = (Year(dt) - 1) & Year(dt)
End If
End Function
0
Commented:
In a query, you can use this expression

fyear: Iif(Month(rdate) >= 4, Year(rdate) & (Year(rdate) + 1), (Year(rdate) - 1) & Year(rdate))
0
CIOCommented:
You may find use for this generic function which "shifts" a calendar date to a date of the financial year:
``````Public Function DateFinancial( _
ByVal datDate As Date) _
As Date

' Number of months from start of calendar year to start of financial year.
Const clngMonthOffset As Long = 3

Dim datFinancial      As Date

DateFinancial = datFinancial

End Function
``````

Now, armed with this, you can easily build your label for the financial year of a date:

strFinancialYear = Year(DateFinancial(rdate)) & Year(DateFinancial(rdate)) + 1

/gustav
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
Are you sure you've got the date right for the start of each financial year - here in the UK each new financial year begins on April 6th (not April 1st)?

http://en.wikipedia.org/wiki/Fiscal_year
0
Commented:
In case you're interested, you can determine the United Kingdom financial year like this:
``````Public Function fyear(rDate As Date) As String

If Month(rDate) < 4 Or _
(Month(rDate) = 4 And _
Day(rDate) < 6) Then
fyear = Year(rDate) - 1
Else
fyear = Year(rDate)
End If
fyear = fyear & fyear + 1

End Function
``````
0
Commented:
In Canada, it goes 1Apr to 31Mar - actually you can start on any month, but it is always the first of the start month to the 31st of the previous month next year.
0
Consultant Anesthesiologist and Pain PhysicianAuthor Commented:
Thanks for the prompt support that provoked solutions for some other countries as well
0
CIOCommented:
You are welcome!

/gustav
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.