473,587 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_firstdat e.Text, Me.dtp_lastdate .Text) + 1

mod_rptStaffCas eloadAnalysis.p _numDaysInSelec tedPeriod = 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>h2uGpHNzI0O uwyE/NFvrug==</Id>
Nov 21 '05 #1
1 2931
"Chris Hill via .NET 247" <an*******@dotn et247.com> wrote in message
news:eQ******** ******@TK2MSFTN GP10.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_firstdat e.Text,
Me.dtp_lastdate .Text) + 1

mod_rptStaffCas eloadAnalysis.p _numDaysInSelec tedPeriod =
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>h2uGpHNzI0O uwyE/NFvrug==</Id>


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

Dim temp as DateTime = Me.dtp_firstdat e.Value
Dim count as Integer

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

Case DayOfWeek.Satur day, DayOfWeek.Sunda y '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
8050
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 values will be stored into a database and at the same time there will be an e-mail generated and send to me that contains the starting date en the end...
2
4733
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 form has Two textboxes to enter dates From Date - Fdate To Date - TDate
5
6723
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 i have extracted into a report writer. Look forward to hearing.. Cheers... SimonC
3
3106
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 working week definition. Lets say I have a working week definition of Monday through Friday, 9 am to 5 pm. Date1 = January 1st, 2005 at 8 am
3
365
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 DaysInRange As Long DaysInRange = DateDiff("d", Me.dtp_firstdate.Text, Me.dtp_lastdate.Text) + 1 ...
3
18078
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
1996
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. So if I were to look at a record for a newspaper publication and see 9 in the field, I could interpret that as meaning the publication was...
2
1946
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 weekend days
1
7203
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: ------------- USE GO --This function is used to count the number of weekdays between -- two dates. create function udf_Weekdays(@Weekday,@BeginDate...
0
7918
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8206
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6621
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5713
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1185
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.