国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Access > 正文

統(tǒng)計某個日期區(qū)間內星期天的個數(shù)

2024-09-07 19:04:06
字體:
來源:轉載
供稿:網(wǎng)友
文章正文:
'功能:算出某個日期區(qū)間內星期天的個數(shù)
'作者:竹笛
'修改歷史:2005/12/30
'未經(jīng)嚴格測試,有問題請與作者交流

Function SundayCount(StartDate As Date, EndDate As Date) As Long
On Error GoTo Err_SundayCount:
Dim Days As Integer '區(qū)間天數(shù)
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
'如果天數(shù)大于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 "周日數(shù)目是: " & SundayCount
Exit Function
End If
NextSunday = NextSunday + 7
i = i + 1
SundayCount = SundayCount + 1
Debug.Print "周日數(shù)目是: " & SundayCount
Next
Else
SundayCount = 0
End If
Else
SundayCount = 0
End If
Exit_SundayCount:
Exit Function
Err_SundayCount:
SundayCount = 0
Resume Exit_SundayCount
End Function

Sub Test()
Debug.Print SundayCount(#2/6/2005#, #2/25/2005#)
End Sub

 

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 东兰县| 灵璧县| 永善县| 三亚市| 祁东县| 广德县| 嘉定区| 哈巴河县| 临海市| 河曲县| 肥西县| 庆云县| 临邑县| 辰溪县| 定陶县| 广饶县| 临沂市| 青冈县| 嘉鱼县| 应城市| 吉木萨尔县| 疏勒县| 万盛区| 军事| 石门县| 庆安县| 台前县| 河曲县| 黎川县| 屏山县| 漳浦县| 界首市| 平阳县| 龙岩市| 沂南县| 东乌| 逊克县| 长顺县| 武义县| 仪征市| 洛南县|