>>*--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 >>>>
>&& 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 >*-------------------------------------------------------------------------- > >