Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Get list of weekdays in current month

Hi

What VB.net code would  I use to get a list of the dates for working days from the start of the current month
up to today's date
Avatar of kaufmed
kaufmed
Flag of United States of America image

Weekdays or working days? (There is a difference.)
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I just improved Tomlinson's code by using the function AddDays:
Public Shared Function GetTotalWorkingDays() As List(Of DateTime)
	Dim weekDays As New List(Of DateTime)()
	Dim today As DateTime = DateTime.Now
	Dim dt As DateTime = today.AddDays(1 - today.Day)
	While dt <= today
		If dt.DayOfWeek >= DayOfWeek.Monday AndAlso dt.DayOfWeek <= DayOfWeek.Friday Then
			weekDays.Add(dt)
		End If
		dt = dt.AddDays(1)
	End While
	Return weekDays
End Function

Open in new window

Avatar of Murray Brown

ASKER

Thanks
Would have been nice to get an answer to my question  : \