
December 4th, 2003, 02:29 AM
|
 |
Gogga
|
|
Join Date: Sep 2003
Location: A long, long time ago, in a galaxy, far, far away...
Posts: 34
Time spent in forums: < 1 sec
Reputation Power: 7
|
|
You can do some pretty neat stuff using the dateAdd function. This should do the trick for what you need (there is a few problems with this code, for instance if you say month 11, week 1, day 1, it will give you a date in month 10 - try it, and you'll see what I mean)
Code:
iYear = 2003
iMonth = 11
'Change the month to an integer. You can use a switch
'statement for this.
iWeekOfMonth = 2
iDayOfWeek = 2
dtDate = iYear & "/" & iMonth & "/01"
'Get the date of the first day of the month
dtDate = DateAdd("ww", iWeekOfMonth - 1, dtDate)
'add the number of weeks to the date
iNumberMoreDays = iDayOfWeek - Weekday(dtDate)
'Calculate the number of days that should be added
dtDate = DateAdd("d", iNumberMoreDays, dtDate)
'Add the number of days
MsgBox (dtDate)
Hope this helps.
|