Carl,
Thanks, look like a solution.
Regards
Lucas
"Carl Prothman [MVP]" <carlpr@spamcop.net> wrote in message
news:efDbdikXDHA.2620@TK2MSFTNGP09.phx.gbl...[color=blue]
> "Lucas Sain" <lsain@lidersoft.com> wrote[color=green]
> > How can I return the Total days between 2 dates but have it only sum the
> > WeekDays and not Weekends. for example Lets say: How many days have[/color][/color]
pasted[color=blue][color=green]
> > from August 4(Monday) to August 10(Sunday) should return 5 days and not[/color][/color]
7.[color=blue][color=green]
> >[/color]
>
> Here is one way....
>
> Given the following function:
>
> Private Function GetNonWeekendDayTotal(ByVal StartDate As DateTime,[/color]
ByVal EndDate As DateTime) As Integer[color=blue]
>
> Dim totalWeekDays As Integer = 0
>
> For i As Integer = 1 To EndDate.Subtract(StartDate).Days
> If StartDate.AddDays(i).DayOfWeek() <> DayOfWeek.Saturday And[/color]
_[color=blue]
> StartDate.AddDays(i).DayOfWeek() <> DayOfWeek.Sunday Then
>
> totalWeekDays += 1
> End If
> Next
>
> Return totalWeekDays
> End Function
>
> Call it as follows:
>
> Dim i As Integer = GetNonWeekendDayTotal( _
> New DateTime(2002, 8, 4, New[/color]
GregorianCalendar(GregorianCalendarTypes.USEnglish )), _[color=blue]
> New DateTime(2002, 8, 10, New[/color]
GregorianCalendar(GregorianCalendarTypes.USEnglish )))[color=blue]
>
> For the GregorialCalendar class, you'll need to the following import:
>
> Imports System.Globalization
>
> --
>
> Thanks,
> Carl Prothman
> Microsoft ASP.NET MVP
>
http://www.able-consulting.com
>
>
>
>[/color]