Fridays date

IanT

Registered User.
Local time
Today, 00:39
Joined
Nov 30, 2001
Messages
191
Hi

Does anyone no how to identify the Fridays date from a inputted date.

i.e DateSorted FridayDate
21-Oct-02 25-Oct-02
23-Oct-02 25-Oct-02


Thanks in advance................
 
You could try:
Code:
Function NextNDay(ByVal pDay As Date, wday As Integer) As Date
NextNDay = [pDay] - WeekDay([pDay]) + wday + IIf(WeekDay([pDay]) >= wday, 7, 0)
End Function
...which you can call from the debug window with:

? nextnday(#10/21/02#, vbFriday)
10/25/02

To go in the opposite direction, try:
Code:
Function LastNDay(pDay As Date, wday As Integer) As Date
LastNDay = [pDay] - (WeekDay([pDay]) + IIf(WeekDay([pDay]) <= wday, 7, 0) - wday)
End Function
...which would return the previous specified day, e.g.

? lastnday(#10/21/02#, vbFriday)
10/18/02
 

Users who are viewing this thread

Back
Top Bottom