Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Number of Mondays in a month
Message
From
20/10/2016 07:25:00
 
 
To
20/10/2016 01:48:35
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01642129
Message ID:
01642138
Views:
79
>>The application has to determine how many occurrences of a given day of the week occurred in a given calendar month.
>>
>>For example- How many Mondays (or any other specified day of the week) were there in February, 2016?
>>I can see how to get the answer by looping through all the days in the month in question, but is there a slicker way?
>
>1. Calculate the # of days in the month
>2. If #days = 28, answer is 4
>3. If #days greater than 28, look at the first ( #days - 28 ) days of the month. If any of those are the one you want, the answer is 5. Otherwise it's 4
>
>i.e. for November (30 days) look at the first ( 30 - 28 ) = 2 days. If you want Mondays, if November 1 or November 2 is a Monday, the answer is 5, otherwise 4.
>
>For February 2016 (29 days), look at the first ( 29 - 28 ) = 1 day. If February 1 is a Monday (and it is), the answer is 5. Any other day of the week the answer is 4.

Thank you, Al.
I'll try that one too.
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Reply
Map
View

Click here to load this message in the networking platform