Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding Sundays
Message
 
To
12/04/2000 12:08:15
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00358746
Message ID:
00358778
Views:
15
>>I need to find all Sundays in a given month.
>>
>>Thanks and Gog Bless,
>>S.Dyke
>
>
lparameters tnMonth, tnYear
>ldStart=ctod("^"+str(tnYear,4)+"/"+padl(int(tnMonth),2,"0")+"/"+"01")
>ldEndDay = gomonth(ldStartDay,1)-day(gomonth(ldStartDay,1))
>for ix = 0 to day(ldEndDay)
> ? ldStart+ix, dow(ldStart+ix,2) = 7 && Sunday
>endfor
Cetin

...and we also have
LPARAMETER tmonth, tyear

LOCAL lddate, lndow
* Get the first day of the month
lddate = DATE(tyear, tmonth, 1)
* Get its DOW() Making sure 1 = Sunday and 7 = Saturday
lndow = DOW(lddate, 1)
* Get the first Sunday, if it isn't
IF lndow # 1
  lddate = lddate + (8 - lndow)
ENDIF
DO WHILE MONTH(lddate) = tmonth
  ? lddate
  lddate = lddate + 7
ENDDO
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform