473,511 Members | 17,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find Every Other Friday

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
3 3030
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
5716
by: Matt | last post by:
My ASP page allows the user select the date, and it will display the report during that week of that date. My question is when the program query database, I need to know the beginning date and...
4
1861
by: michaaal | last post by:
How can I get a list of the date of every friday of the year? I realize this code is wrong, but maybe you'll see what I am after... Sub GetFridayList() For x = 1 to len(Date(2004)) if...
20
5004
by: Laguna | last post by:
Hi Gurus, I want to find the expiration date of stock options (3rd Friday of the month) for an any give month and year. I have tried a few tricks with the functions provided by the built-in...
11
15931
by: CK | last post by:
Hi All, Looking for a simple function to return the date for the follwing Friday. I send out emails from time to time and I would like a function that dynamically returns the date for the...
5
3692
by: vj | last post by:
I'm doing: a = now() delta = ReltaiveDateTime(days=+6, weekday(mx.DateTime.Friday, 0)) Next Friday: a+delta a: march 23 a+delta: Gives me March 31st and not March 24th Any ideas?
1
1157
by: ibiza | last post by:
Hi all, I need to find a specific, for example the third friday of a given month/year. How to do that? thanks :)
10
32726
by: sherifffruitfly | last post by:
Hi all, This is how I'm currently getting Friday of last week. It strikes me as cumbersome. Is there a slicker/more elegant way? Thanks for any ideas, cdj
1
2183
by: Matt | last post by:
I have table that has the following fields: JobNumber WeekEndingDate ReportRequired_01 ReportRequired_02 every Friday morning the weekending date changes. I need to automatically generate...
3
6103
by: ats | last post by:
Does anybody have any sample code for calculating the date for teh last Friday in each month. TIA -- ats@jbex When an old lady got hit by a truck I saw the wicked gleam in your eyes
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.