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?
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?
DatePart('dddd', now)
or
DatePart('dddd', #1/1/2010#)
...with an explicit date.
Just subtract 7 days from the current date then get friday from that.
edit:
SET @CurDate = DATEADD(dd,-7,@CurDate);
if( DATEPART(dw,@CurDate)=6 )
BEGIN
END
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
Dim LastFridayDate As Date
iWeekday = Weekday(Now(), vbFriday)
LastFridayDate = Format(Now - (iWeekday - 1), "dd-mmm-yy")
End Sub