统计某个日期区间内星期天的个数
时 间:2006-01-03 00:00:00
作 者:竹笛 ID:8 城市:上海 QQ:2851379730
摘 要:统计某个日期区间内星期天的个数
正 文:
'作者:竹笛
'修改历史:2005/12/30
'未经严格测试,有问题请与作者交流
Function SundayCount(StartDate As Date, EndDate As Date) As Long
On Error GoTo Err_SundayCount:
Dim Days As Integer '区间天数
Dim FirstSunday As Date '第一个周日具体日期
Dim NextSunday As Date '下一个周日具体日期
Dim Myweekday As Integer
Dim i As Long
Dim j As Long
'确保日期都不为空,若为空则置为0
If Not IsNull(StartDate) And Not IsNull(EndDate) Then
'如果结束日期<开始日期,则为0
If EndDate >= StartDate Then
'如果天数大于7,则先确定第一个周日是哪个日期,再7天一加,直到大于结束日期
Days = EndDate - StartDate
' If Days > 7 Then
Myweekday = Weekday(StartDate) '算出是周几,星期天是1
If Myweekday > 1 Then
FirstSunday = StartDate + 8 - Myweekday
Else
FirstSunday = StartDate
End If
Debug.Print "最近的周日是: " & FirstSunday
NextSunday = FirstSunday + 7
i = 1
SundayCount = 1
For i = 1 To Days Step 7
Debug.Print "下一个周日是: " & NextSunday
If NextSunday > EndDate Then
If FirstSunday > EndDate Then
SundayCount = SundayCount - 1
End If
Debug.Print "周日数目是: " & SundayCount
Exit Function
End If
NextSunday = NextSunday + 7
i = i + 1
SundayCount = SundayCoun
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access高效办公】统计当...(06.30)
- 【Access高效办公】用复选...(06.24)
- 根据变化的日期来自动编号的示例...(06.20)
- 【Access高效办公】按日期...(06.12)
- 合并列数据到一个文本框的示例;...(05.06)
- 通过命令按钮让Access列表...(04.24)
- 【Access高效办公】统计当...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)

学习心得
最新文章
- 关于Access交叉表查询生成的统...(08.02)
- ACCESS做的工作日常小工具_纸...(07.30)
- Access快速开发平台进销存教程...(07.28)
- 关于Access快速开发平台2.6...(07.23)
- 【Access交叉表查询】按百分比...(07.21)
- VBA编程-ADO-关于对象早晚期...(07.17)
- Access快速开发平台--frm...(07.15)
- 1行代码实现Access与SQL ...(07.09)
- 免费《仓库管理实战课程》全集(07.08)
- Access快速开发平台--Win...(07.07)