Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First Friday of the Month

Status
Not open for further replies.

royalcheese

Technical User
Dec 5, 2005
111
GB
Hi all im trying to find the first friday in specified year / month . The code below adds 6 days on but i think im interperating the DateInterval.day wrong.

Code:
Date_CurrentFriday1 = Format(DateAdd(DateInterval.Day, FirstDayOfWeek.Friday, DateSerial(RDyear, RDmonth, 1)), ShortFormat)

[\code]
 
Here's a quick and dirty function I threw together that should do the job:

Code:
    Private Function FirstFriday(ByVal month As Integer, ByVal year As Integer) As Date
        Dim d As New Date(year, month, 1)
        While d.DayOfWeek <> DayOfWeek.Friday
            d = d.AddDays(1)
        End While
        Return d
    End Function

I'm not sure if you can do that with DateAdd.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top