Article ID: 132101
Article Last Modified on 1/19/2007
Query: GetFiscalDates
-------------------------------------------------------------------
Field: OrderDate
Table: Orders
Criteria: Like "*/*/94"
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
NOTE: In Microsoft Access 1.x and 2.0, there is a space in the Order
Date field name.
Field: FYear: Year([FieldName])-IIf([FieldName]< _
DateSerial(Year([FieldName]),9,15),1,0)
Field: FMonth: (Month([FieldName])+IIf(Day([FieldName])<15,9,10)-1) _
Mod 12+1
If the fiscal year begins on 9/15 of the previous calendar year, you can
modify the FYear expression as follows:
Field: FYear: Year([FieldName])-IIf([FieldName]< _
DateSerial(Year([FieldName]),9,15),1,0)+1
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.
Function GetFiscalYear (ByVal x As Variant)
If x < DateSerial(Year(x), FMonthStart, FDayStart) Then
GetFiscalYear = Year(x) - FYearOffset - 1
Else
GetFiscalYear = Year(x) - FYearOffset
End If
End Function
Function GetFiscalMonth (ByVal x As Variant)
Dim m
m = Month(x) - FMonthStart + 1
If Day(x) < FDayStart Then m = m - 1
If m < 1 Then m = m + 12
GetFiscalMonth = m
End Function
? GetFiscalYear (#7/1/95#)
Note that this line returns the year 1996.
? GetFiscalMonth (#8/1/95#)
Keywords: kbhowto kbprogramming KB132101