473,487 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need Count Working Day

1 New Member
Hi, Guys

I am creating application in ms-access and i am struggling to counting working days when user gives start date and end date. i don't want to count saturday and sunday.
So, anyone can help how can i do it. i would be very appreciate if you provide me coding for that.

Thanks,
Dec 22 '06 #1
1 2253
ADezii
8,834 Recognized Expert Expert
Hi, Guys

I am creating application in ms-access and i am struggling to counting working days when user gives start date and end date. i don't want to count saturday and sunday.
So, anyone can help how can i do it. i would be very appreciate if you provide me coding for that.

Thanks,
This should work nicely for a Generic Code Template
Expand|Select|Wrap|Line Numbers
  1. Dim intNoOfDays As Integer, intCounter As Integer
  2. Dim MyDates() As Date, T As Integer, intNoOfWeekdays As Integer
  3. Dim dteStartDate As Date, dteEndDate As Date
  4.  
  5. dteStartDate = #1/1/2007#   'Starting Date
  6. dteEndDate = #1/31/2007#    'Ending Date
  7.  
  8. intNoOfDays = DateDiff("d", dteStartDate, dteEndDate)   'Days between
  9.  
  10. ReDim MyDates(intNoOfDays)
  11.  
  12. MyDates(0) = dteStartDate   '1st Element in the Array
  13.  
  14. For intCounter = 1 To intNoOfDays   'Initialize other Elements
  15.   MyDates(intCounter) = DateAdd("d", intCounter, dteStartDate)  'place Dates into Array
  16. Next intCounter
  17.  
  18. If intNoOfDays > 0 Then
  19.   For T = 0 To UBound(MyDates)  'Loop through Array
  20.     If Weekday(MyDates(T)) > 1 And Weekday(MyDates(T)) < 7 Then     'Weekends would have values of 1 or 7
  21.       intNoOfWeekdays = intNoOfWeekdays + 1
  22.     End If
  23.   Next T
  24. Else
  25. End If
  26.  
  27. MsgBox "The Number of Weekdays is: " & intNoOfWeekdays
Dec 22 '06 #2

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

Similar topics

8
2178
by: Rick | last post by:
I have a program that reads from a file. In the file are a series of words. I read in all the words into a string array, find the average length, count the number of words, display the longest...
2
1316
by: Greier Matthias | last post by:
Hi! I've got a sport-database for my students with name - class - teacher - year of birth - 60meter-runningtime - 100meter - longjump - ...(and some other disciplines) The whole program...
13
2165
by: XXXXXX.working.in.my.blood | last post by:
hi all, i need help with linked lists... the problem is this, "reverse the contents of a singly linked list without using a temporary node"... solution with code will be appreciated...
4
1117
by: Binh | last post by:
Hi, I write a C# to get information from a XML site, when I run my program at home, there's no problem. But when in office (no proxy, no firewall, port 80 is open), I've got this error: ...
5
2704
by: manmit.walia | last post by:
Hello All, I am stuck on a conversion problem. I am trying to convert my application which is written in VB.NET to C# because the project I am working on currently is being written in C#. I tried...
7
2817
by: Gasten | last post by:
Hello. The last weeks I've been coding a roguelike (you know, like nethack) in python using the nCurses library. Some week ago I ran into a problem: When I made the object for messagebar-output, I...
8
2093
by: Patti | last post by:
I am new to SQL and have created a stored procedure for a .net web application. Unfortunately I had to use a cursor in the stored procedure, so it is taking several minutes to execute because it...
2
1748
by: manontheedge | last post by:
I'm trying to learn multithreading in C. I've never done it before, and I've spent several hours reading about it, and looking at examples. I found this example and have been messing with it (I've...
1
2588
by: muld | last post by:
I've inherited a database system designed to calculate sickness absence statistics. There is a main table with an employee ID which also holds the number of days worked by that person in a year ....
5
2144
by: Justin | last post by:
Here's my XML: <?xml version="1.0" ?> <AppMode Type="Network"> <CurrentFolder Path="c:\tabs"> <Tabs> <FilePath>tabs\Justin.tab</FilePath> <FilePath>tabs\Julie.tab</FilePath> *****There could...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
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,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
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
7349
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...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
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.