If Weekday(DateAdd("d", 14, Now())) = 5 Then
MsgBox "Its thursday!"
Else
MsgBox "Its Not!"
End If
mission2java_78 said:Code:If Weekday(DateAdd("d", 14, Now())) = 5 Then MsgBox "Its thursday!" Else MsgBox "Its Not!" End If
Mile-O-Phile said:
That only determines if the date two weeks from today is a Thursday or not.
Mile-O-Phile said:=DateSerial(Year(Date), Month(Date), 1) + IIf(5 < Weekday(DateSerial(Year(Date), Month(Date), 1)), 7 - Weekday(DateSerial(Year(Date), Month(Date), 1)) + 5, 5 - Weekday(DateSerial(Year(Date), Month(Date), 1))) + 14
Function NthXDay(pDate As Variant, pWDay As Integer, pIncrement As Integer) As Date
'*******************************************
'Name: NthXDay (Function)
'Purpose: Find the nth occurence of a weekday
' within any given month, with Sunday = 1
' through Saturday = 6
'Inputs: To find the 3rd Thursday of Sep 2003
' ? NthXDay(#9/24/03#, 5, 3)
'Output: 9/18/03
'*******************************************
Dim dteDate As Date, newDate As Date
'find the first day of the month
dteDate = DateSerial(Year(DateValue(pDate)), Month(DateValue(pDate)), 1)
'move to the first pWDay
newDate = dteDate - WeekDay(dteDate) + pWDay + IIf(WeekDay(dteDate) > pWDay, 7, 0)
'move to the specified (pIncrement -1) occurence of pWday
newDate = DateAdd("d", 7 * (pIncrement - 1), newDate)
NthXDay = newDate
End Function
Or my onliner:cvdate("01 " & format(date(),"mmm yyyy")) - weekday(cvdate("01 " & format(date(),"mmm yyyy")),vbfriday)+21Mile-O-Phile said:=DateSerial(Year(Date), Month(Date), 1) + IIf(5 < Weekday(DateSerial(Year(Date), Month(Date), 1)), 7 - Weekday(DateSerial(Year(Date), Month(Date), 1)) + 5, 5 - Weekday(DateSerial(Year(Date), Month(Date), 1))) + 14