Find Every Other Friday

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Has anyone written any code to find the date of every other Friday of the year?
Is there an easy way of doing this?
 
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
 
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
 
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

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

My creditors thank you. LOL, I setup a program to log into my bank
account, and pay my bills every other Friday. Would you believe you
couldn't set this up via their web tool?!?!? Thanks to the group
again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top