PDA

View Full Version : Meeting Date Function


ABC123

Charles Hoens
02-21-2003, 08:51 AM
Does anyone know if there is a meeting date function? This function would allow a user to calculate dates for meetings that might occur on the 4th Wednesday of each month. I'm thinking that something like this would be quite useful (at least I need it for this app of mine)!! The function would need to be given the year, month, week number and day of week (just thinking out loud) to work.

I looked in the Code Archive and also on Dr. Wayne's site, but couldn't find anything.

I'll start working on this, because I need it, but any ideas or help would be greatly appreciated.

Charlie

Charles Hoens
02-21-2003, 09:38 AM
OK. I got it done faster than I thought, so here's the code. It's fairly simple:

FUNCTION MeetDate AS N (CYear AS C, CMon AS C, WkNum AS N, NDay AS N)
dim stday as n
stday=dow(ctod(cmon+"/01/"+cyear))
if stday=Nday then
meetdate=(wknum*7)+1
end if
if stday>Nday then
meetdate=(wknum*7)-(stday-nday)+1
else
meetdate=(wknum*7)-(nday-stday)+1
end if
END FUNCTION


Be careful of the word wrap!!

Now what I need is for someone out there to enhance the code so that improper entry of wrong number of weeks, or invalid dates won't return bad results.

Good luck. I hope someone can use this.

Charlie

Charles Hoens
02-21-2003, 10:54 AM
SORRY!!!

It's getting bad when you have to reply to your own posts!!

Found an error, so here's the corrected code:

'Date Created: 21-Feb-2003 02:43:35 PM
'Last Updated: 21-Feb-2003 03:23:10 PM
'Created By : Charles H. Hoens
'Updated By : Charles H. Hoens
FUNCTION MeetDate AS N (CYear AS C, CMon AS C, WkNum AS N, NDay AS N)
dim stday as n
stday=0
stday=dow(ctod(cmon+"/01/"+cyear))
if stday=Nday then
meetdate=((wknum-1)*7)+1
else if stday>Nday then
meetdate=((wknum-1)*7)+(7-stday+nday)+1
else if stday

Tom Seeley
10-21-2004, 11:53 PM
Bless You!!! We meet on the fourth Wednesdqy of the month, and I didn't know I needed this until I saw it. WOW! is my life easier when passing information on to prespective members. THANKS!

Stan Mathews
11-16-2004, 08:18 AM
I think the html ate one of your """ signs.

'Date Created: 21-Feb-2003 02:43:35 PM
'Last Updated: 21-Feb-2003 03:23:10 PM
'Created By : Charles H. Hoens
'Updated By : Charles H. Hoens
FUNCTION MeetDate AS N (CYear AS C, CMon AS C, WkNum AS N, NDay AS N)
dim stday as n
stday=0
stday=dow(ctod(cmon+"/01/";+cyear))
if stday=Nday then
meetdate=((wknum-1)*7)+1
else if stday " Nday then
meetdate=((wknum-1)*7)+(7-stday+nday)+1
else if stday " Nday then
meetdate=((wknum-1)*7)+(nday-stday)+1
end if

END FUNCTION