# VB6 - Find first and second sunday dates of 2 months

HI

I'm trying to find the second Sunday date of February from current year and also the first Sunday date of December from current year.

The first Sunday date of February of current year would show in Text1 and the second Sunday date of December of current year would show in Text2.

How can i do this.

LVL 11
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RetiredCommented:
This expert suggested creating a Gigs project.
Use this function:
``````Function GetNthWeekdayInMonth(iYear As Integer, iMonth As Integer, iTargetDOW As Integer, n As Integer) As Date
Dim iFirstWeekDayOfMonth As Integer
Dim dtFirstiTargetDOWinMonth As Date
Dim dtFirstWeekday As Date

iFirstWeekDayOfMonth = Weekday(DateSerial(iYear, iMonth, 1))
dtFirstiTargetDOWinMonth = DateSerial(iYear, iMonth, 1 + ((iTargetDOW - iFirstWeekDayOfMonth + 7)) Mod 7)
GetNthWeekdayInMonth = DateAdd("d", 7 * (n - 1), dtFirstiTargetDOWinMonth)
End Function
``````

So for the second Sunday in February
``````Text1.text = GetNthWeekdayInMonth(Year(Now), 2, vbSunday, 2)
``````
and the first Sunday in December:
``````Text2.Text = GetNthWeekdayInMonth(Year(Now), 12, vbSunday, 1)
``````
1

Experts Exchange Solution brought to you by