Excelに依存しない日付関数(WeekDay)です。
1 | 日曜 |
2 | 月曜 |
3 | 火曜 |
4 | 水曜 |
5 | 木曜 |
6 | 金曜 |
7 | 土曜 |
Public Type Day_Def
yy As Integer
mm As Integer
dd As Integer
End Type
Public Function Date_WeekDay(Day_F As Day_Def) As Integer
Dim YY_W As Integer
Dim MM_W As Integer
Dim Dd_W As Integer
Dim Y1_W As Integer
Dim Y2_W As Integer
Dim Cal1_W As Integer
Dim Cal2_W As Integer
Dim Cal3_W As Integer
Dim Cal9_W As Integer
YY_W = Day_F.yy
MM_W = Day_F.mm
Dd_W = Day_F.dd
If MM_W < 3 Then
YY_W = YY_W - 1
MM_W = MM_W + 12
End If
Y1_W = Int(YY_W / 100)
Cal1_W = Int(Y1_W / 4)
Y2_W = YY_W - Int(YY_W / 100) * 100
Cal2_W = Int(Y2_W / 4)
Cal3_W = Int(26 * (MM_W + 1) / 10)
Cal9_W = Cal1_W - Y1_W * 2 + Y2_W + Cal2_W + Cal3_W + Dd_W - 1
Do Until Cal9_W >= 0
Cal9_W = Cal9_W + 7
Loop
Date_WeekDay = Cal9_W - Int(Cal9_W / 7) * 7
Date_WeekDay = Date_WeekDay + 1
End Function
|