473,503 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting days

1 New Member
For MS Access database

Can anyone give me a hand in creating a procedure/query to select the number of Mondays, or Tuesdays, or Wednesdays (or any other day of the week from the seven) occurring within a given period when two dates are inserted? Would appreciate tremendously

Thanks
Feb 2 '08 #1
1 1100
ADezii
8,834 Recognized Expert Expert
For MS Access database

Can anyone give me a hand in creating a procedure/query to select the number of Mondays, or Tuesdays, or Wednesdays (or any other day of the week from the seven) occurring within a given period when two dates are inserted? Would appreciate tremendously

Thanks
The following litte code snippet will Print the number of Mondays and Wednesdays between January 1, 2008 and the Current Date. This should point you in the right direction:
Expand|Select|Wrap|Line Numbers
  1. Dim dteStartDate As Date, dteEndDate As Date
  2. Dim intNoOfMonAndWeds As Integer, intDaysDiff As Integer
  3. Dim intCounter As Integer, dteTestDate As Date
  4.  
  5. Const conMONDAY As Integer = 2
  6. Const conWEDNESDAY As Integer = 4
  7.  
  8. dteStartDate = #1/1/2008#
  9. dteEndDate = Now()
  10. intDaysDiff = DateDiff("d", dteStartDate, dteEndDate)
  11.  
  12. For intCounter = 0 To intDaysDiff
  13.   dteTestDate = DateAdd("d", intCounter, dteStartDate)
  14.     If Weekday(dteTestDate) = conMONDAY Or Weekday(dteTestDate) = conWEDNESDAY Then
  15.       intNoOfMonAndWeds = intNoOfMonAndWeds + 1
  16.     End If
  17. Next
  18.  
  19. Debug.Print "The number of Mondays and Wednesdays between " & dteStartDate & " and " & _
  20.              Format$(dteEndDate, "m/d/yyyy") & " is " & intNoOfMonAndWeds
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. The number of Mondays and Wednesdays between 1/1/2008 and 2/2/2008 is 9
Feb 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
1940
by: Ian Rastall | last post by:
In a project mentioned in another thread, I'm trying to get some dynamic data to work. In this discography, you can click on an album name, and the title of the album and its tracks will appear on...
2
11213
by: C.F. Scheidecker Antunes | last post by:
Hello all, I wonder if is there any way to select from a table all the records which has a Date Field that is at least five minutes old? In other words, I have a table with a date field and I...
0
1824
by: Robert Kilroy | last post by:
Greetings, I'm sure there's an answer out there to this question. But I've been looking for about 2 days and haven't found it yet. Maybe I'm just not asking the right question. I need to get...
1
2971
by: fnord | last post by:
I'm in a bit of a mess here, trying to deal with some timestamp issues. I need to select items from a database with a datetime timestamp: 0000-00-00 00:00:00 I need to select these items...
2
1903
by: Robert | last post by:
Hi All, I'm trying to solve this for a few days now and I just can't figure it out... I have three tables set up, I'll simplify them for this question: Table 1: HOTELS Columns: HOTEL_ID,...
2
1985
by: Catherine | last post by:
I have a database where in my query I need to be able to locate accounts that show a date greater than 14 days from the current date. How would I structure this to allow for all accounts that over...
2
1611
by: Phrogz | last post by:
Years ago I wrote a library to turn normal <selectsinto text inputs that the user can type in, with various features. In those days, I was working for an IE-centric company, so I didn't spend the...
9
16901
by: ice | last post by:
Hello, I have a couple of tables. The client tables and the contacted tables. I am not sure how to start on this, what I need is a way to query all my clients then show any client that the...
2
1523
by: .nLL | last post by:
got below script, works fine with IE but fails on opera. my js knowledge is very limited and can't find whats wrong with it. ---------------------------------------------- function...
3
1897
by: Shawn | last post by:
I'm trying to go through a large number of logically named textboxes using a loop and cannot figure out how short of explicitly referencing every single one.
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.