473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I calculate the number of weekdays between 2 dates :?

Hi

I'm a jnr developer in need of desparate help. Can anyone point me in the right direction for this problem:

I calculate the number of days between 2 user defined dates like this:
Dim DaysInRange As Long

DaysInRange = DateDiff("d", Me.dtp_firstdate.Text, Me.dtp_lastdate.Text) + 1

mod_rptStaffCaseloadAnalysis.p_numDaysInSelectedPe riod = DaysInRange

What I need to do now, is work out the number of weekdays (Mon-Fri) between the dates selected by the user.

I am completely stumped.

Can anyone provide some pointers?

Thanks!

--------------------------------
From: Chris Hill

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>h2uGpHNzI0OuwyE/NFvrug==</Id>
Nov 21 '05 #1
1 2897
"Chris Hill via .NET 247" <an*******@dotnet247.com> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
Hi

I'm a jnr developer in need of desparate help. Can anyone point me in the
right direction for this problem:

I calculate the number of days between 2 user defined dates like this:
Dim DaysInRange As Long

DaysInRange = DateDiff("d", Me.dtp_firstdate.Text,
Me.dtp_lastdate.Text) + 1

mod_rptStaffCaseloadAnalysis.p_numDaysInSelectedPe riod =
DaysInRange

What I need to do now, is work out the number of weekdays (Mon-Fri)
between the dates selected by the user.

I am completely stumped.

Can anyone provide some pointers?

Thanks!

--------------------------------
From: Chris Hill

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>h2uGpHNzI0OuwyE/NFvrug==</Id>


You could simply iterate the dates like (air code):

Dim temp as DateTime = Me.dtp_firstdate.Value
Dim count as Integer

While temp <= Me.dtp_lastdate.Value
Select Case temp.DayOfWeek

Case DayOfWeek.Saturday, DayOfWeek.Sunday 'do nuthing

Case Else

count += 1

End Select

temp = DateAdd("d", 1, temp)

End While
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tiernan | last post by:
Hi all I'm looking for a way to find the number of weekdays between 2 dates In my form I have three fields for a begin date (dd)(mm)(yyyy) and three for the end date (dd)(mm)(yyyy) Now these...
2
by: JP SIngh | last post by:
Hi All I need to calculate the number of working days between the two dates entered on an ASP page. I am not that great a coder in ASP and was wondering if someone can help. Basically the...
5
by: SimonC | last post by:
Help needed for a Javascript beginner. As above in the subject... i need a javascript to run this, but not in the form of a web-page. I want to calculate it between 2 fields in a database that...
3
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my...
3
by: Chris Hill via .NET 247 | last post by:
Hi I'm a jnr developer in need of desparate help. Can anyone point me in the right direction for this problem: I calculate the number of days between 2 user defined dates like this: Dim...
3
by: George | last post by:
Can someone tell me how to calculate the number of weeks between two dates. Your help is appreciated. Thanks, George
4
by: MLH | last post by:
I'm thinking of an integer field in which I could write values up to 1+2+4+8+16+32+64 and to use these values later. Each of the individual values would represent a weekday from Sunday to Saturday....
2
by: Mike | last post by:
Is there a way to calculate the total number of weekdays when provided a date? Example: If I have a start date of 7/11/2008 and I want to go out 10 days, I want to get this: 6 weekdays 4...
1
by: bharathreddy | last post by:
This article will explain how we can get the count of weekdays in between two dates. This will be usefull if we want to count the number of working days between two dates. Example: -------------...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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
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...

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.