About This Code
Brief Description:
Calculate current, previous and next fiscal year date ranges
Contributor:
Michael Smelser
Type:
Date/Time functions
Notes Version:
R6.x, R7.x
Last Modified:
10 Nov 2006
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
This bit of code will determine the current, previous and next fiscal years and date ranges. The checking of "thisMonth" can be altered to represent the months needed.
Dim s as New NotesSession
Dim thisDate As New NotesDateTime( Now )
Dim thisMonth As Integer
Dim fiscalyear As Integer, prevfiscalYear As Integer, nextfiscalYear As Integer
Dim dateRange As NotesDateRange, prevdateRange As NotesDateRange, nextdateRange As NotesDateRange
thisMonth = Month( thisDate.DateOnly )
If thisMonth = 10 Or thisMonth = 11 Or thisMonth = 12 Then
fiscalYear = Year( thisDate.DateOnly )
Else
Call thisDate.AdjustYear( -1 )
fiscalYear = Year( thisDate.DateOnly )
End If
prevfiscalYear = fiscalYear - 1
nextfiscalYear = fiscalYear + 1
'Current fiscal year date range
Dim dateTime1 As New NotesDateTime("10/01/" + Cstr( fiscalYear ) )
Dim dateTime2 As New NotesDateTime("09/30/" + Cstr( nextfiscalYear ) )
Set dateRange = s.CreateDateRange()
Set dateRange.StartDateTime = dateTime1
Set dateRange.EndDateTime = dateTime2
'Previous fiscal year date range
Dim dateTime3 As New NotesDateTime("10/01/" + Cstr( prevfiscalYear ) )
Dim dateTime4 As New NotesDateTime("09/30/" + Cstr( fiscalYear ) )
Set prevdateRange = s.CreateDateRange()
Set prevdateRange.StartDateTime = dateTime3
Set prevdateRange.EndDateTime = dateTime4
'Next fiscal year date range
Dim dateTime5 As New NotesDateTime("10/01/" + Cstr( nextfiscalYear ) )
Dim dateTime6 As New NotesDateTime("09/30/" + Cstr( nextfiscalYear + 1 ) )
Set nextdateRange = s.CreateDateRange()
Set nextdateRange.StartDateTime = dateTime5
Set nextdateRange.EndDateTime = dateTime6
Usage / Example