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?
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
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) _
	.Single()

Open in new window

Avatar of T Hoecherl

ASKER

Thank you.