你的算法是法定假期遇到星期6、星期日顺推对吗,
Function Rt_Day(BegDate As Variant) As Long
'***************Code Start**********************************
'
'计算指定月份的天数(扣除星期六、日、法定假期)法定假日如果刚好是双休日,则顺推
'
'BegDate 开始日期及时间
'用法: Rt_day(#2006-7-1#)
'作者: andymark 2006-8-13
'http://bbs.office-cn.net
'
'*********************************************************
Dim Rs As New ADODB.Recordset
Dim DateCnt As Variant
Dim EndDays As Variant
Dim IntDays As Integer
DateCnt = CDate(Format(BegDate, "yyyy-m-1"))
EndDays = DateAdd("d", -1, DateAdd("M", 1, DateCnt))
IntDays = 0
Do While DateCnt <= EndDays
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat" Then
IntDays = IntDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Rs.Open "select * from 法定假日 where 月=" & Format(BegDate, "m") & "", CurrentProject.Connection, adOpenDynamic
If Not Rs.EOF Then
Do While Not Rs.EOF
IntDays = IntDays - 1
Rs.MoveNext
Loop
End If
Rt_Day = IntDays
Set Rs = Nothing
End Function
'*********** Code End **************
[此贴子已经被作者于2006-8-13 20:08:18编辑过]
|