Gustav Brock
gustav at cactus.dk
Mon Jul 19 10:36:26 CDT 2004
Hi Arthur
> Has anyone code some code in hand that would allow me to calculate the
> third Wednesday of every month? Or for that matter just the first
> Wednesday of a given month (to which I'll just add 14)? I don't think
> it's that tough, but thought I'd check to see if someone has it in hand
> before I write it.
I guess these functions could easily be wrapped or modified to your
purpose:
<code>
Public Function DateNextWeekday( _
ByVal datDate As Date, _
Optional ByVal bytWeekday As Byte = vbMonday) _
As Date
' Returns the date of the next weekday, as spelled in vbXxxxday, following datDate.
' 2000-09-06. Cactus Data ApS.
' No special error handling.
On Error Resume Next
DateNextWeekday = DateAdd("d", 7 - (WeekDay(datDate, bytWeekday) - 1), datDate)
End Function
Public Function DateThisMonthLast( _
Optional ByVal datDateThisMonth As Date) As Date
If datDateThisMonth = 0 Then
datDateThisMonth = Date
End If
DatePreviousMonthLast = DateSerial(Year(datDateThisMonth), _
Month(datDateThisMonth) + 1, 0)
End Function
</code>
/gustav