Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Meeting Dates
Message
From
29/03/1999 10:16:41
Jonathan Cochran
Alion Science and Technology
Maryland, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00202952
Message ID:
00202979
Views:
22
>I have a committee that meets on the second Friday of each month, except if the 1st day of the month is a Thursday or Friday, the commitee meets on the third Friday of the month.
>
>On any given date, I need to be able to determine committee meeting dates for the next 3 months.
>
>Thanks for your help.


Try this. I'm sure others on this board could do it a better way, but this seems to work.



PROCEDURE Meetings

? MeetDate( DATE() )
? MeetDate( GOMONTH( DATE(), 1 ) )
? MeetDate( GOMONTH( DATE(), 2 ) )

ENDPROC



**************************************************************
FUNCTION MeetDate

LPARAMETERS td_Today

LOCAL ld_First
LOCAL ln_DayOfWeek
LOCAL ld_Meet


**
** Get first day of month.
**
ld_First = BegOfMonth(td_Today)

**
** Get day of week (1 = Sun, 7 = Sat).
**
ln_DayOfWeek = DOW( ld_First, 1 )

**
** See what day of the week the 1st is on.
**
DO CASE

CASE ln_DayOfWeek = 5

**
** Thu -- Go to tomorrow (Fri), then two weeks after (third Fri).
**
ld_Meet = ld_First + 1 + ( 2 * 7 )

CASE ln_DayOfWeek = 6

**
** Fri -- Go two weeks after (third Fri).
**
ld_Meet = ld_First + ( 2 * 7 )

CASE ln_DayOfWeek = 7

**
** Sat -- Go to yesterday (Fri), then two weeks after (second Fri).
**
ld_Meet = ld_First - 1 + ( 2 * 7 )

OTHERWISE

**
** Sun - Wed -- Go to Fri of this week, then on more week (second Fri).
**
ld_Meet = ld_First + ( 6 - ln_DayOfWeek ) + ( 1 * 7 )

ENDCASE

RETURN ld_Meet

ENDFUNC



**************************************************************
FUNCTION BegOfMonth

LPARAMETERS td_InDate

LOCAL ld_BegOfMonth


ld_BegOfMonth = td_InDate - DAY(td_InDate) + 1


RETURN ld_BegOfMonth

ENDFUNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform