Link to home
Start Free TrialLog in
Avatar of T Hoecherl
T HoecherlFlag for United States of America

asked on

Find date of 2nd Thursday of each month

I need to calculate a date at the beginning of each month which represents the 2nd Thursday of that month.  How can I do that?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi thoecherl;

This Linq query should give you what you need.
Dim today As DateTime = DateTime.Today
' Find the second thursday of the month
Dim secondThursday As DateTime = Enumerable.Range(8, 7) _
	.Select(Function(dayIdx) New DateTime(today.Year, today.Month, dayIdx)) _
	.Where(Function(theDate) theDate.DayOfWeek = DayOfWeek.Thursday) _

Open in new window

Avatar of T Hoecherl


Thank you.