"Mel" <ML********@gmail.comwrote in message
news:cc**********************************@f37g2000 pri.googlegroups.com...
When I use the DateAdd function using "DateInterval.Weekday" it does
not return the correct date, well at least how I thought the weekday
option should work.
A quick glance at the documentation will tell you what DateInterval.Weekday
actually means:
http://msdn.microsoft.com/en-us/libr...einterval.aspx
It is counting weekends and I only want it to count the weekdays
(Mon-Fri).
How can I get it to work? (using Asp.net 2.0, vb.net)
Write your own function, something like this:
Function WeekdayDiff(ByVal pdtmDate As DateTime, ByVal pintInterval As
Integer) As DateTime
Dim intDays As Integer = 1
Do Until intDays pintInterval
pdtmDate = pdtmDate.AddDays(1)
If pdtmDate.DayOfWeek <DayOfWeek.Saturday And pdtmDate.DayOfWeek
<DayOfWeek.Sunday Then
intDays = intDays + 1
End If
Loop
Return pdtmDate
End Function
And call it like this: Dim dtmEnd As DateTime = WeekdayDiff(DateTime.Now,
10)
Also, do yourself a *HUGE* favour and forget about the Microsoft.VisualBasic
"training wheels" namespace...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net