|
- Public Function FstDayOfMth(InDate As Date) As Date
- FstDayOfMth = DateSerial(Year(InDate), Month(InDate), 1)
- End Function
- Public Function FstDayOfNextMnth(InDate As Date) As Date
- FstDayOfNextMnth = DateSerial(Year(InDate), Month(InDate) + 1, 1)
- End Function
- Public Function LstDayMnth(InDate As Date) As Date
- LstDayMnth = DateSerial(Year(InDate), Month(InDate) + 1, 0)
- End Function
- Public Function LstDayNextMnth(InDate As Date) As Date
- LstDayNextMnth = DateSerial(Year(InDate), Month(InDate) + 2, 0)
- End Function
- Public Function FstDayPrevMnth(InDate As Date) As Date
- FstDayPrevMnth = DateSerial(Year(InDate), Month(InDate) - 1, 1)
- End Function
- Public Function LstDayPrevMnth(InDate As Date) As Date
- LstDayPrevMnth = DateSerial(Year(InDate), Month(InDate), 0)
- End Function
- Public Function FstDayCurQtr(InDate As Date) As Date
- FstDayCurQtr = DateSerial(Year(InDate), Int((Month(InDate) - 1) / 3) * 3 + 1, 1)
- End Function
- Public Function LstDayCurQtr(InDate As Date) As Date
- LstDayCurQtr = DateSerial(Year(InDate), Int((Month(InDate) - 1) / 3) * 3 + 4, 0)
- End Function
- Public Function FstDayCurWeek(InDate As Date) As Date
- FstDayCurWeek = InDate - Weekday(InDate) + 1
- End Function
- Public Function LstDayCurWeek(InDate As Date) As Date
- LstDayCurWeek = InDate - Weekday(InDate) + 7
- End Function
- Public Function FstDayCurWeek2(InDate As Date, InStartWeek As Integer) As Date
- 'The first day of the current week (using settings in Options dialog box):
- FstDayCurWeek2 = InDate - Weekday(InDate, InStartWeek) + 1
- End Function
- Public Function LstDayCurWeek2(InDate As Date, InStartWeek As Integer) As Date
- 'The last day of the current week:
- LstDayCurWeek2 = InDate - Weekday(InDate, 0) + 7
- End Function
- Public Function FstWeekDayOfMth(InDate As Date, DayNum As Integer) As Date
- Dim FirstDay As Date
- Dim FirstWeekDay As Integer
- FirstDay = DateSerial(Year(InDate), Month(InDate), 1)
- FirstWeekDay = Weekday(FirstDay)
- Select Case FirstWeekDay
- Case Is < DayNum
- FstWeekDayOfMth = FirstDay + DayNum - FirstWeekDay
- Case Is = DayNum
- FstWeekDayOfMth = FirstDay
- Case Else
- FstWeekDayOfMth = FirstDay + DayNum - FirstWeekDay + 7
- End Select
- End Function
复制代码 |
|