Information générale
Catégorie:
Codage, syntaxe et commandes
>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
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement