Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How many Sundays in a month?
Message
From
21/03/2001 18:09:10
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00487391
Message ID:
00487441
Views:
6
I tried a function on this. Worked for the months of this year, but didn't test others.
lnMonth = 3
lnYear = 2001

IIF(dow(date(lnYear,lnMonth,1))=1,1,9-dow(date(lnYear,lnMonth,1)))  && first Sunday in month

gomonth(date(lnYear,lnMonth,1),1)-date(lnYear,lnMonth,1)    && no. of days in month

If first Sunday + 28 days (4 more Sundays) is less < = no. of days in month,
we have 5 Sunday, otherwise there are 4.  So the function is:

IIF((IIF(dow(date(lnYear,lnMonth,1))=1,1,9-dow(date(lnYear,lnMonth,1)))+28) <= (gomonth(date(lnYear,lnMonth,1),1)-date(lnYear,lnMonth,1)),5,4)
Rod Poujade
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform