Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

neat way to get last friday's date

Tags:

vba

no matter what day I call the function on.

I know I could write a select case weekday(now) statement, was just wondering if there was a neater way to go?

like image 350
Nick Avatar asked Jan 19 '10 15:01

Nick


2 Answers

Does this help get you started? I just gave it a quick test and seemed to work ok.

Private Sub LastFriday()

    Dim iWeekday As Integer, LastFridayDate As Date

    iWeekday = Weekday(Now(), vbFriday)

    LastFridayDate = Format(Now - (iWeekday - 1), "dd-mmm-yy")

End Sub
like image 182
Alex P Avatar answered Nov 13 '22 05:11

Alex P


DateAdd("d", -1 - Weekday(Now), Now)

like image 44
Nick Avatar answered Nov 13 '22 03:11

Nick