How would you rate this article?
Rating:
0 user(s) have rated this article
Posted by:
retro
Date:
24/12/2008
Category:
Web Development
Views:
this article has been read 936 times
Recent Articles

(26/06/2010)
Nochex merchant accounts provide you with everything you need to accept payments on your web site. With no monthly fees and support for a number of ecommerce solutions, including nopCommerce, it has never been easier to start selling online!
|
(25/05/2010)
Check out our latest project for community interest company S.C.A.
|
(25/05/2010)
We are pleased to announce support for version 4.0 of the .NET Framework on all of our hosting plans.
|
(11/02/2010)
We have just completed development of a new web site for UK based Aerial Spares.
|
(11/02/2010)
Today sees the release of the official nopCommerce user guide. It explains every part of the application in detail and includes a getting started guide so you can get up and running quickly.
|
read more
There is already a DateDiff function you can use to calculate the number of days between two dates. A common requirement is to calculate the number of working days between two dates (Monday - Friday).
Private Function WorkingDateDiff(ByVal startDate As DateTime, ByVal endDate As DateTime) As Integer
Dim WorkingDaysCount As Integer = 0
For i As Integer = 0 To DateDiff(DateInterval.Day, startDate, endDate)
If Not ((startDate.AddDays(i).DayOfWeek) = DayOfWeek.Saturday) AndAlso _
Not ((startDate.AddDays(i).DayOfWeek = DayOfWeek.Sunday)) Then
WorkingDaysCount += 1
End If
Next
Return WorkingDaysCount
End Function
This function loops through each date in the range and counts the number of days, providing it is not a Saturday or Sunday. This does not take into account public holidays, but you could quite easily extend the function to check an array of dates containing public holidays.