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 07:56:06
 
 
À
10/03/2008 03:32:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01300363
Message ID:
01300414
Vues:
18
Thanks Gregory, I really appreciate it. I was having a brain-dead evening I think because as soon as Bo posted, I realized how clear it was. I should have caught it. I kept thinking in my mind for some reason that I had to go to the last day of the month and count backwards. Brain cramp! :o)


>>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
>*--------------------------------------------------------------------------
>
>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform