Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Last day of month, last tuesday of month, etc
Message
De
10/03/2008 03:32:18
 
 
À
09/03/2008 20:22:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01300363
Message ID:
01300394
Vues:
18
This message has been marked as a message which has helped to the initial question of the thread.
>I can figure out if it is the 1st, 2nd, 3rd, or 4th Monday of the current month (or Tuesday, Wednesday, et al). Doing something similar to:
>
>*--4th Saturday of the month
>
>*--Is today the 4th Saturday of the month?
>ldxDate = DATE()
>IF DOW(ldxDate) = 7
>      FOR i = DAY(ldxDate-1) TO 0 STEP -1  && up to and including today
>            IF DOW(ldxDate-i) = 7 && Saturday
>                  lnCounter = lnCounter + 1 && increment the # of times we found a Saturday
>                  IF lnCounter = 4  && 4th time
>                        IF i = 0 && today
>                              ll4thSaturday = .T.  && today is the 4th Saturday
>                        ENDIF
>                        EXIT
>                  ENDIF
>            ENDIF
>      ENDFOR
>ENDIF
>
>
>But how do I determine if today is the LAST Saturday, Sunday, Monday, etc of the month?
_____________________
Tracy,

In addition ...

The function below goes to the first sun/mon/.... starting at a certain date
&& eg: first Sunday starting with {^2008/03/10}
? date_ToFirst_day({^2008/03/10}, 1) && {^2008/03/16}

&& && eg: first Monday starting with {^2008/03/10}
? date_ToFirst_day({^2008/03/10}, 2) && {^2008/03/10} since it is a monday

Then 
   - the last sunday of a month is the first sunday of the next month - 7 days
   ? Month_Date_lastDay({^2008/03/10}, 1) && && {^2008/03/30} last sunday

   - the 4th saturday is the first saturday + 3 * 7 days
     ie, feed the function with the beginning of the month


Is today the last sunday ?
 ? Month_Date_lastDay(date(), 1) == date()

*--------------------------------------------------------------------------

function date_ToFirst_day(d, DayNumber)  && US
	return m.d + mod(7 - dow(m.d, 1) + m.DayNumber, 7)
endfunc

*function date_ToFirst_day(d, DayNumber) && Europe
*	return m.d + mod(7 - dow(m.d, 2) + m.DayNumber, 7)
* endfunc

*--------------------------------------------------------------------------
function Month_Date_lastDay(d, DayNumber)
	
	return date_ToFirst_day(gomonth(bomonth(m.d), 1), m.DayNumber) - 7
endfunc
*--------------------------------------------------------------------------
function bomonth(d) && beginning of month
	return m.d+1-day(m.d)
endfunc
*--------------------------------------------------------------------------
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform