Avatar of T Hoecherl
T Hoecherl
Flag 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?
Visual Basic.NET

Avatar of undefined
Last Comment
T Hoecherl

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mike Tomlinson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Fernando Soto

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

T Hoecherl

ASKER
Thank you.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck