There are a lot of ways to do this, but I'd do the following. Add two
functions to a general module:
Function FiscalYearEnd(TheDate As Date) As Date
If Month(TheDate) >= 1 And Month(TheDate) < 7 Then
FiscalYearEnd = DateSerial(Year(TheDate), 6, 30)
Else
FiscalYearEnd = DateSerial(Year(TheDate) + 1, 6, 30)
End If
End Function
Function FiscalYearBegin(TheDate As Date) As Date
If Month(TheDate) >= 1 And Month(TheDate) < 7 Then
FiscalYearBegin = DateSerial(Year(TheDate) - 1, 7, 1)
Else
FiscalYearBegin = DateSerial(Year(TheDate), 7, 1)
End If
End Function
These functions will find the beginning and ending dates of whatever date is
provided it. To use them, (and I am assuming you want values from THIS
fiscal year), just use the built in Date() function as the parameter value.
Like this:
SELECT * FROM MyTable WHERE InspectionDate BETWEEN FiscalYearBegin(Date) AND
FiscalYearEnd(Date)
The beauty of these functions is if you gave any date in the last fiscal
year, it will return last year's fiscal begin and end dates.
--
--Roger Carlson
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L