By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,175 Members | 1,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,175 IT Pros & Developers. It's quick & easy.

Find Every Other Friday

P: n/a
Has anyone written any code to find the date of every other Friday of the year?
Is there an easy way of doing this?
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Peter,

Do you mean something as this?
\\\
If Now.DayOfWeek = DayOfWeek.Friday Then
MessageBox.Show("Today it is Friday")
End If
///

I hope this helps?

Cor
Has anyone written any code to find the date of every other Friday of the year? Is there an easy way of doing this?

Nov 21 '05 #2

P: n/a
Peter,
Do you want to start with the first or second Friday of the year?

Here is a routine that will print every other Friday starting with the first
Friday after the start date, going until the last Friday before the end
date.

Private Shared Sub PrintEveryOtherWeek(ByVal startDate As DateTime,
ByVal endDate As DateTime)
Dim friday As DateTime = startDate.AddDays(DayOfWeek.Friday -
startDate.DayOfWeek)

Do Until friday > endDate
Debug.WriteLine(friday, "friday")
friday = friday.AddDays(14)
Loop
End Sub

Public Shared Sub Main()
PrintEveryOtherWeek(Today, Today.AddYears(1))
End Sub

Just replace the Debug.WriteLine with the logic that you need. You can
change the range by setting the start date & end date as appropriate, for
example:

PrintEveryOtherWeek(New DateTime(2004, 1, 1), New DateTime(2005, 1,
1))

Note you need to decide if the end date needs to be inclusive or exclusive.
I made it exclusive in the above example.

Hope this helps
Jay

"Peter" <pe***@mclinn.com> wrote in message
news:dc**************************@posting.google.c om...
Has anyone written any code to find the date of every other Friday of the year? Is there an easy way of doing this?

Nov 21 '05 #3

P: n/a
Hi,
Not sure if you are looking for something like this:

Dim t As DateTime = New DateTime (2004, 1, 2) 'First Friday of the year
While (t.Year = 2004)
Console.WriteLine (t)
t.AddDays (14) 'Every other Friday
End While

"Peter" <pe***@mclinn.com> wrote in message
news:dc**************************@posting.google.c om...
Has anyone written any code to find the date of every other Friday of the
year?
Is there an easy way of doing this?
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.