Dim session As New notessession
Dim db As notesdatabase
Dim strFilePath As String
Dim i As Integer '循环变量
Dim Int_Days As Integer '总间隔天数
Dim Int_Workdays As Integer '间隔的工作日
Dim doc1 As notesdocument
Dim doc2 As notesdocument
Dim Date_Begin As NotesDateTime '起始日
Dim Date_End As NotesDateTime '结算日
Dim Date_Variant As NotesDateTime '临时日
Dim CalendarDb As notesdatabase '基本信息日
Dim view1 As notesview
Dim view2 As notesview
Dim Str_Date As String '日期字符串
Set db=session.currentdatabase
strFilePath="calendar.nsf"
Set CalendarDb = New notesdatabase(db.server,strFilePath)
Set view1=Calendardb.getview("holiday")
Set view2=Calendardb.getview("workday")
Set Date_Begin = New NotesDateTime( "Today" )
Set Date_End = New NotesDateTime( "27/09/2006" )
Int_Days = Date_Begin.TimeDifference(date_end)/86400 '计算间隔总天数
Set Date_Variant = New NotesDateTime(Date_Begin.DateOnly) '变量日期指向第一天
Int_Workdays = 0
For i = 1 To Int_Days
Call Date_Variant.AdjustDay(1,True) '日期向后移一天
If Weekday(date_Variant.DateOnly )=1 Or Weekday(Date_Variant.DateOnly )=7 Then '如果是周末
Set doc1=view2.GetFirstDocument
Do While Not(doc1 Is Nothing)
Str_Date = doc1.workday(0)
If Date_Variant.DateOnly = Format(Str_Date,"yyyy-mm-dd") Then
Int_Workdays = Int_Workdays + 1 '如果是工作日则加1天
Exit Do
End If
Set doc1=view2.GetNextDocument(doc1)
Loop
Else '如果不是周末
Set doc2=view1.getfirstdocument
Int_Workdays = Int_Workdays + 1 '不是 周末加1天
Do While Not(doc2 Is Nothing)
Str_Date = doc2.holiday(0)
If Date_Variant.DateOnly = Format(Str_Date,"yyyy-mm-dd") Then
Int_Workdays = Int_Workdays - 1 '如果是节假日则再减掉
Exit Do
End If
Set doc2=view1.GetNextDocument(doc2)
Loop
End If