Formula to change thurs/fri/mon/tues to previous wed

phillipmai

Registered User.
Local time
Today, 22:44
Joined
Dec 29, 2009
Messages
19
Hello,

I have a date field that I need to be able to do the following, if it is dated between thurs-tues then the date should be the previous Wednesday.
 
Try this function in a Standard Module:
Code:
Public Function DateAdjust(InDate As Date) As Date

'-- If InDate is not Wednesday then adjust it back to the previous Wednesday.
   If Weekday(InDate, vbMonday) = 3 Then
      '-- InDate is a Wednesday, just return it.
      DateAdjust = InDate
   Else
      '-- Adjust the InDate to the previous Wednesday's Date
      DateAdjust = InDate - Weekday(InDate, vbThursday)
   End If

End Function
 
Thanks much appreciated!
 

Users who are viewing this thread

Back
Top Bottom