Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Article ID: 210249 - Last Review: October 11, 2006 - Revision: 2.2
HOW TO: Get the Fiscal Year or Month of a Particular Date in Access
2000
This article was previously published under Q210249
This article shows you how to get the fiscal year or fiscal month of a particular
date by using an expression or a user-defined function.
Query: GetFiscalDates
------------------------------------------------------------
-------
Field: OrderDate
Table: Orders
Criteria: DatePart("yyyy",[OrderDate])=1997
Field: FYear: Year([OrderDate])-IIf([OrderDate]< _
DateSerial(Year([OrderDate]),6,16),1,0)
Field: FMonth: (Month([OrderDate])+IIf(Day([OrderDate])
<16,6,7)-1) _
Mod 12+1
3. Run the query, and then scroll through the query datasheet. Note that
the fiscal year and fiscal month appear for each record in the Orders
table.
You can use the FYear and FMonth expressions in your database by modifying
the Date field, the day and the month, to the appropriate values for your fiscal
year. For example, if the fiscal year begins on 9/15 of the current calendar
year, you can modify the previous expressions as follows:
http://support.microsoft.com/kb/210249 13/04/2009
HOW TO: Get the Fiscal Year or Month of a Particular Date in Access 2000 Page 2 of 4
If the fiscal year begins on 9/15 of the previous calendar year, you can modify
the FYear expression as follows:
1. Create a module and type the following lines in the Declarations section:
Option Explicit
Const FMonthStart = 6 ' Numeric value representing the first
month
' of the fiscal year.
Const FDayStart = 16 ' Numeric value representing the first
day of
' the fiscal year.
Const FYearOffset = -1 ' 0 means the fiscal year starts in the
' current calendar year.
' -1 means the fiscal year starts in
the
' previous calendar year.
http://support.microsoft.com/kb/210249 13/04/2009
HOW TO: Get the Fiscal Year or Month of a Particular Date in Access 2000 Page 3 of 4
3. To test these functions, type each of the following lines in the Immediate
window, and then press ENTER after each one:
?GetFiscalYear(#7/1/1999#)
?GetFiscalMonth(#8/1/1999#)
Note that this line returns the number 2. The 2 represents the second
month in the fiscal year.
For more information about the DateSerial function, click Microsoft Access
Help on the Help menu, type DateSerial, Day, Month, and Year function
examples in the Office Assistant or the Answer Wizard, and then click Search
to view the topic.
APPLIES TO
http://support.microsoft.com/kb/210249 13/04/2009
HOW TO: Get the Fiscal Year or Month of a Particular Date in Access 2000 Page 4 of 4
http://support.microsoft.com/kb/210249 13/04/2009