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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calc specific weekday of the Month

Status
Not open for further replies.

tjs32

Programmer
Jun 21, 2004
26
AU
I know how to calculate the dayname of a date field. However from that date how do I then calculate that day in a specific week.

Example - (date format dd/mm/yyyy)

Datefield = 01/11/2005

I want to calculate 01/11/2005 is the first Tuesday in the month and then calculate the next first Tuesday which would be 06/12/2005

Any Help would be appreciated
 
Hi
Maybe:
Code:
Function SameDayNextMonth(intYear, intMonth, intDay)
Dim dteDateIn As Date, dteNewDate As Date
dteDateIn = DateSerial(intYear, intMonth, intDay)
dteNewDate = DateSerial(intYear, intMonth + 1, 1)
Do While Weekday(dteNewDate) <> Weekday(dteDateIn)
    dteNewDate = dteNewDate + 1
Loop
SameDayNextMonth = dteNewDate
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top