[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

return count of number of Sundays in any given month

Posted on 2004-08-30
2
Medium Priority
?
288 Views
Last Modified: 2012-06-27
I'd like to put code in a textbox's control source that returns the total number of Sundays in any given month. For instance, this month would return the #5. Thanks
0
Comment
Question by:robsking
2 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 2000 total points
ID: 11938066
This is a function that uses a brute force method:

Function GetSundays(dtDate As Date) As Long
Dim I As Long

For I = DateSerial(Year(dtDate), Month(dtDate), 1) To DateSerial(Year(dtDate), Month(dtDate) + 1, 0)
   If Weekday(I, vbSunday) = 1 Then GetSundays = GetSundays + 1
Next
End Function

Set the control source of your textbox to:
=GetSundays(Date())

to get the number of Sundays in the current month, or a date in any particular month to retrieve the number of Sundays in that month.
0
 

Author Comment

by:robsking
ID: 11938091
Works for me. Thanks
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question